Hello. I am making a betting gui that is supposed to be usable by all players. I don't know if this is correct. So basically, it makes a textbutton and plus the bet value by 1 when you click it. There is a timer too (30 second timer to bet). I kinda got stuck because it randomly picks a player and then everyone that bet on that player would get their coins doubled. Here is the script,
while wait(600) do -- wait 10 minutes before it appears again
script.Parent.Frame.Visible = true
for i, v in pairs(game.Players:GetPlayers()) do -- gets all players
local button = Instance.new("TextButton", script.Parent.Frame) -- sets a bunch of stuff like making textbuttons for every person
button.Text = v.Name
button.BackgroundTransparency = 0.75
button.BackgroundColor3 = Color3.new(Vector3.new(0,0,0))
local betsLabel = Instance.new("TextLabel", button)
local bets = Instance.new("IntValue", betsLabel)
betsLabel.Text = bets.Value
betsLabel.BackgroundTransparency = 1
betsLabel.TextColor3 = Color3.new(Vector3.new(255,255,255))
v.MouseButton1Click:connect(function()
bets.Value = bets.Value + 1
end)
for i = 30, 0, -1 do -- timer
local timeL = Instance.new("TextLabel", script.Parent.Frame)
timeL.Text = "Time Left: ".. i
if i == 0 then -- when timer is done it randomly picks someone
math.random() -- got stuck here
end
end
end
end
The parts im concerned about is the randomizing part and the places where it creates the textlabels and such.

1 comment
I edit the script. Please check it.