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

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

Asked by 9 years ago

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.

0
Where in the player is the value located? dyler3 1510 — 9y

1 answer

Log in to vote
1
Answered by 9 years ago

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.

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. Perci1 4988 — 9y
0
I know. I use ChildAdded because it fires with test mode in Studio. bobafett3544 198 — 9y
0
I think they actually changed PlayerAdded in a recent update so it fires in play solo. Perci1 4988 — 9y
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? Devotional 210 — 9y
0
Try the current code, and if it doesn't work, I'll change it. bobafett3544 198 — 9y
Ad

Answer this question