I have a script that changes a value inside of replicated storage when a player joins or leaves. Here is my script:
wait(1)
local Players = game:GetService("Players") --gets players
local value = script.Parent.PlayersOnline
local PlayerCount = #Players:GetPlayers() --gets the amount of players
Players.PlayerAdded:Connect(function() --if a player gets added,
PlayerCount = PlayerCount + 1 --increase the playercount by 1
value.Value = PlayerCount
end)
Players.PlayerRemoving:Connect(function() --if a player gets removed,
PlayerCount = PlayerCount - 1 --decrease the playercount by 1
value.Value = PlayerCount
end)
When someone joins, the value doesn't change for some reason. Any suggestions?

4 comments
I dont know, bro, have you checked the Developer Console or that thing (F9) and it may say the error, maybe a wrong variable, i dont know, check that again
There are no errors, sorry.
Is this a LocalScript or a Server Script?
This is a script.