I’m attempting to make a countdown system which will trigger once at least 8 players have joined the queue, when a players clicks on the “Play” button it should count add 1 player to the count and remove it if the player leaves the game or clicks the “Back” button, the problem is that it will only count the player that triggered the count, for example, if I control 2 players and I make both of them join the queue the count will change display a 1 for both players when it is supposed to display a 2.
I haven’t tried anything yet except for making the script print after every single command, the result i got had something curious, there was a “A player has joined the queue” message printed once for each player on their own output, however the server’s output was empty. I haven’t tried anything else since I don’t really know where the error is.
This is the local script in charge of counting if a player joined the queue, it should be located inside every player’s play button.
local mouse = game.Players.LocalPlayer:GetMouse()
local sound = game.Workspace.Sound
local frame = script.Parent
local players = game.Workspace.Players
local teams = game:GetService("Teams")
function hover()
script.Parent.TextLabel.TextXAlignment = ("Center")
script.Parent.ImageButton.Size = UDim2.new(0.753, 0, 0, 0)
sound:Play()
end
function unhover()
script.Parent.TextLabel.TextXAlignment = ("Left")
script.Parent.ImageButton.Size = UDim2.new(0.461, 0, 0, 0)
end
function less()
print("A player has left the queue")
players.Value = players.Value - 1
end
function more()
print("A player has joined the queue")
players.Value = players.Value + 1
end
function click()
if players.Value < 15 then
script.Parent.Parent.Info.Active = false
script.Parent.Parent.Info.Visible = false
script.Parent.Parent.Shop.Active = false
script.Parent.Parent.Shop.Visible = false
script.Parent.Parent.Play.Active = false
script.Parent.Parent.Play.Visible = false
script.Parent.Parent.Exit.Active = true
script.Parent.Parent.Exit.Visible = true
script.Parent.Parent.PlayMenu.Active = true
script.Parent.Parent.PlayMenu.Visible = true
game.Players.LocalPlayer.TeamColor = BrickColor.new("Shamrock")
script.Parent.Parent.Title.Text = ("PLAY")
end
end
teams.Queued.PlayerRemoved:Connect(less)
teams.Queued.PlayerAdded:Connect(more)
frame.MouseEnter:Connect(hover)
frame.MouseLeave:Connect(unhover)
frame.MouseButton1Click:Connect(click)
This is my second post on these forums so if I committed any kind of mistake let me know, thanks beforehand
.