So let's say I have a LocalScript under StarterPlayerScripts with the following code:
local player = game.Players.LocalPlayer local function onTeamChange(someArgs) --Do stuff on the client end
...how can I get the onTeamChange() function to fire when the player changes teams?
I have some possible solutions:
Doing something like this:
player.Changed:Connect(onTeamChange)
and then check if the Changed property was "Team", or
or
The thing is, I want to do this as efficiently as possible (by efficiently, I mean that it is less costly for the server/client, and thus does not generate much lag, even if there are many players in the server together) The problem with option 2 is that it is very inefficient, as the loop would be always running and it would contribute to lag for the potato computer players. The thing with option 1 is that it would fire every single time a property is changed, which I don't think is very efficient either, and the problem with option 3 is that there has to be a lot of server-client communication, especially when there are many people in the server.
So which of these would be the most effective/neatest to do? Which one would you use? Is it one of these, or have I overlooked something? Anything helps, thanks for your time :D