Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why isn't this clone for loop working on all players it only works on 1 player?

Asked by
H3kken -4
5 years ago

Okay, so I made this script for a minigame-game but somehow at the last line (which isn't a end line) it clones a gui only in 1 player's playergui. Here's the script.

game.Players.PlayerAdded:Connect(function(plr)

workspace:WaitForChild("PlayerCount").Value = workspace.PlayerCount.Value + 1

end)

game.Players.PlayerRemoving:Connect(function()

workspace:WaitForChild("PlayerCount").Value = workspace.PlayerCount.Value - 1

end)

workspace:WaitForChild("PlayerCount").Changed:Connect(function()

wait(1)

if workspace.PlayerCount.Value == 1 then

for i,v in pairs(game.Players:GetPlayers()) do

game.Lighting:WaitForChild("Waiting2Players"):Clone().Parent = v:WaitForChild("PlayerGui")

end

elseif workspace.PlayerCount.Value == 2 or workspace.PlayerCount.Value >= 2 then

for i,v in pairs(game.Players:GetPlayers()) do

v.PlayerGui:WaitForChild("Waiting2Players"):remove()

game.Lighting.ChoosingMinigame:Clone().Parent = v:WaitForChild("PlayerGui")

end

end

end)

It also has a player counter in it, you may have noticed. Anyone knows how to fix this?

0
I understand StackEdit may be hard to use, but can you try to use the code block? Makes it easier to read. Clorize 31 — 5y

Answer this question