Advertisement
Guest User

Untitled

a guest
Feb 18th, 2020
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. local wins = {}
  2. local bidsTotal = 10
  3. local list = {}
  4. local starting = false
  5. function getChance(playerMoneyValue)
  6.  
  7. return playerMoneyValue/bidsTotal
  8. end
  9.  
  10. function a(wins)
  11. for i=1,#wins do
  12. if wins[1][2] > wins[2][2] then
  13. table.remove(wins,2)
  14. script.Parent.RemoteEvent:FireClient(game.Players[wins[2][1]],false)
  15. elseif wins[1][1] < wins[2][2] then
  16. table.remove(wins,1)
  17. script.Parent.RemoteEvent:FireClient(game.Players[wins[1][1]],false)
  18. end
  19. end
  20. end
  21. function random(playerList)
  22. if typeof(playerList) == typeof({}) then
  23. for i=0,#playerList do
  24. print('AA')
  25. local firstPlayer = playerList[1]
  26. if firstPlayer then
  27. local name = firstPlayer["Name"]
  28. local chance = firstPlayer["Chance"]
  29.  
  30. table.insert(wins,{firstPlayer["Name"],math.random(0,chance)})
  31. table.remove(playerList,1)
  32. else
  33. break
  34. end
  35. end
  36. for i=0,1,-1 do
  37. if #wins <= 1 then
  38. break
  39. else
  40. a(wins)
  41. end
  42. end
  43. end
  44. end
  45.  
  46. script.Parent.RemoteFunction.OnServerInvoke = function(player,money)
  47. print('OK')
  48.  
  49. print(player.Money.Value >= money )
  50. if player.Money.Value >= money then
  51. if money > 100 then
  52. player.Money.Value = player.Money.Value - money
  53. print('OK')
  54. starting = true
  55. table.insert(list,{["Name"] = player.Name,["Chance"] = getChance(player.Money.Value)})
  56. bidsTotal = bidsTotal + money
  57. return "Entered The Random Giveaway!"
  58. else
  59. return "Money Should Be Atleast 100'"
  60. end
  61. else
  62. return "Insufficient Funds"
  63. end
  64. end
  65.  
  66. while wait(10) do
  67. print('a')
  68. print(unpack(wins))
  69. random(list)
  70. print(unpack(wins))
  71. if starting and wins[1][1] then
  72. print(wins[1][1])
  73. script.Parent.RemoteEvent:FireClient(game.Players[wins[1][1]],true)
  74. game.Players[wins[1][1]].Money.Value = game.Players[wins[1][1]].Money.Value + bidsTotal
  75. wins = {}
  76. starting = false
  77.  
  78.  
  79. end
  80. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement