I have a script here:
Counter = Instance.new("IntValue", workspace)
Counter.Name = "PlayerCount"
Counter.Value = #game.Teams.Eliminating:GetPlayers()
print(Counter.Value)
game.Workspace.PlayerCount.Changed:connect(function()
if Counter.Value < 1 or Counter.Value == 1 then
game.Workspace.Ground:Destroy()
print("Ground has melted")
game.Lighting.Ground:Clone().Parent = game.Workspace
print("Snow has refrosen")
wait(3)
for _, player in ipairs(game.Players:GetPlayers()) do
player.Team = game.Teams.Eliminating
print("Teams have changed")
end
end
end)
The problem is that, when I print the counter value, it always gives me 0, even if I am in the team, can someone explain why, and possibly give me a fix?

1 comment
Because you're relying on a constant variable. The value never changes from when the game first loads up. To fix this, move line 3 inside the .Changed event function.