Here is the script I'm using, I'm not sure why it isn't working. Can anybody help?
PlayerCount = game.ReplicatedStorage.Players.Value game.Players.PlayerAdded:connect(function() PlayerCount = PlayerCount + 1 end) game.Players.PlayerRemoving:connect(function() PlayerCount = PlayerCount - 1 end)
You get the value and not re-assign the value to the Actual Value-Object try something like this:
PlayerCount = game.ReplicatedStorage.Players game.Players.PlayerAdded:connect(function() PlayerCount.Value = PlayerCount.Value + 1 end game.Player.PlayerRemoving:connect(function() PlayerCount.Value = PlayerCount.Value - 1 end
but why even use a custom thing if you can just use
game.Players.NumPlayers
If it's in the Replicated Storage, I suggest you use NumberValues which are easier to use.
If you changed to NumberValue then try with this script; NOTE: Make sure it's a script in ServerScriptService
local PlayerCount = game.ReplicatedStorage:WaitForChild("Players").Value --Make sure Players is a NumberValue game.Players.PlayerAdded:connect(function() PlayerCount = PlayerCount + 1 end) game.Players.PlayerRemoving:connect(function() PlayerCount = PlayerCount - 1 end)
If helped then please accept answer and upvote. If you have problems comment on errors or other things.