Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local wins = {}
- local bidsTotal = 10
- local list = {}
- local starting = false
- function getChance(playerMoneyValue)
- return playerMoneyValue/bidsTotal
- end
- function a(wins)
- for i=1,#wins do
- if wins[1][2] > wins[2][2] then
- table.remove(wins,2)
- script.Parent.RemoteEvent:FireClient(game.Players[wins[2][1]],false)
- elseif wins[1][1] < wins[2][2] then
- table.remove(wins,1)
- script.Parent.RemoteEvent:FireClient(game.Players[wins[1][1]],false)
- end
- end
- end
- function random(playerList)
- if typeof(playerList) == typeof({}) then
- for i=0,#playerList do
- print('AA')
- local firstPlayer = playerList[1]
- if firstPlayer then
- local name = firstPlayer["Name"]
- local chance = firstPlayer["Chance"]
- table.insert(wins,{firstPlayer["Name"],math.random(0,chance)})
- table.remove(playerList,1)
- else
- break
- end
- end
- for i=0,1,-1 do
- if #wins <= 1 then
- break
- else
- a(wins)
- end
- end
- end
- end
- script.Parent.RemoteFunction.OnServerInvoke = function(player,money)
- print('OK')
- print(player.Money.Value >= money )
- if player.Money.Value >= money then
- if money > 100 then
- player.Money.Value = player.Money.Value - money
- print('OK')
- starting = true
- table.insert(list,{["Name"] = player.Name,["Chance"] = getChance(player.Money.Value)})
- bidsTotal = bidsTotal + money
- return "Entered The Random Giveaway!"
- else
- return "Money Should Be Atleast 100'"
- end
- else
- return "Insufficient Funds"
- end
- end
- while wait(10) do
- print('a')
- print(unpack(wins))
- random(list)
- print(unpack(wins))
- if starting and wins[1][1] then
- print(wins[1][1])
- script.Parent.RemoteEvent:FireClient(game.Players[wins[1][1]],true)
- game.Players[wins[1][1]].Money.Value = game.Players[wins[1][1]].Money.Value + bidsTotal
- wins = {}
- starting = false
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement