Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can I get this script to keep up with players?

I know the question wasn't clear, so I'll explain it more here. When I say that, I'm asking, how can I get a server script to keep up with a value inside a player?(example: stringvalue)

Would it would use something like the .Changed event? If so, how would you get the script to find the each and every player?

And this isn't for only new players entering the server so I don't think PlayerAdded will help.

1 comment

0

Where in the player is the value located?

1 answer

PlayerAdded or ChildAdded would work.

game.Players.ChildAdded:connect(function(player)
local value = Instance.new("StringValue", player)
value.Changed:connect(function(change)
--code here
end)
end)

The reason this works is because when a player joins, the event keeps the player and tracks them. That's why the .Chatted event works past the first chat. Just remember to make other scripts to manipulate the StringValue and stuff.

5 comments

0

You really should use PlayerAdded when your only purpose is to keep track of players that join the game, since ChildAdded keeps track of every instance added. I know nothing else will ever be inside Players, but you should still use PlayerAdded.

0

I know. I use ChildAdded because it fires with test mode in Studio.

0

I think they actually changed PlayerAdded in a recent update so it fires in play solo.

0

I already created the value inside the Player from the start. I'm talking about how would I reference to everybody's value as soon as it's updated?

0

Try the current code, and if it doesn't work, I'll change it.

This discussion is preserved as it was. New answers, comments, and votes are closed.