Hey, I'm trying to build a sort of 'Ready Up' button. Essentially, when enough players in the game click the button (8 in this situation), the game begins, although I haven't programmed that part yet.
Right now, I'm working on listing how many players have actually pressed the button in the "TL" variable as seen in my script below:
local n = 0
local RemoteEvent = game.ReplicatedStorage.RemoteEvent
local RemoteEvent2 = game.ReplicatedStorage.RemoteEvent2
local debounce = false
local debounce2 = false
RemoteEvent.OnServerEvent:Connect(function(plr)
local TL = plr.PlayerGui.MainMenu.PlayMenu.TextLabel
local ReadyUpButton = plr.PlayerGui.MainMenu.PlayMenu.Frame.Ready
ReadyUpButton.MouseButton1Click:Connect(function()
if debounce == false then
debounce2 = false
n = n + 1
TL.Text = n .. "/8 Players"
debounce = true
end
end)
end)
RemoteEvent2.OnServerEvent:Connect(function(plr)
local TL = plr.PlayerGui.MainMenu.PlayMenu.TextLabel
local BackButton = plr.PlayerGui.MainMenu.PlayMenu.Frame.Back
BackButton.MouseButton1Click:Connect(function()
if debounce2 == false then
debounce2 = true
debounce = false
wait(2)
n = n - 1
TL.Text = n .. "/8 Players"
end
end)
end)
For context, there are 2 screens in my game. When you start the game, there is a "Main Menu" screen which consists of a "Play Button" that takes you to another screen. This screen has both the 'BackButton' and 'ReadyUpButton'. The BackButton takes you back to the Main Menu and the Ready Up Button readies you up (or increases n in this case). 'n' is the amount of players that have ready'd up, so when you press the back button n decreases by 1 and when you press ready up n increases by 1.
I am pretty new to Remote Events (and scripting in general at that), so there are a few bugs with the "Readying Up" part.
Firstly, when actually testing this script on a public server, if one player presses the "ReadyUpButton", 'n' doesn't go up by one on other player's screens but it does with the local player. For the number to actually go up on other player's screens, they have to press the 'BackButton' and then the 'ReadyUpButton' again. This isn't the only problem. If one player has already Ready'd up, the 'ReadyUpButton' does not increase 'n'.
Can I get some help here?

1 comment
This was EXTREMELY useful. I have yet to understand a couple things that you mentioned here and the specific details of how this works, but I will be sure to look into it. Thank you!