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

Is it possible to have multiple events activating the same function?

Asked by 9 years ago

Is it possible for multiple things to activate 1 function? For example, would this work?

Player.leaderstats.Gold.Value.Changed,Player.leaderstats.Gems.Value.Changed,Player.Exp.Value.Changed:connect(saveStats)

1 answer

Log in to vote
2
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
9 years ago

Yes, but that's not the syntax. You have to use the connect method on each and every event you want to connect:

Player.leaderstats.Gold.Changed:connect(saveStats)
Player.leaderstats.Gems.Changed:connect(saveStats)
Player.Exp.Changed:connect(saveStats)

EDIT: Also, the Changed event of a ValueObject is in the object itself, not the Value property.

0
Oh, and also, how would I find a LocalPlayer for the connect line in a regular script? I know that LocalPlayer only works with LocalScript, so how would I do something similar with the regular scripts? SlickPwner 534 — 9y
0
The PlayerAdded event gives you a player arguement, so just create a parameter for it! :) adark 5487 — 9y
Ad

Answer this question