Done on the client, in a screengui in startergui
local LocalPlayer = game:GetService("Players").LocalPlayer
LocalPlayer:GetPropertyChangedSignal("Team"):Connect(function()
print("Jarvis, submit post to https://devforum.roblox.com/latest .")
end)
It doesn’t work here but works in a client script in starterplayerscripts, im thinking maybe it can only be used in one script at a time?
It will work only in client script because LocalPlayer exist only on client side. And its obviously player who playing your game itself.
The whole thing is a bit vague… what changed properties are you trying to detect?
And LocalPlayer only works on LocalScript as what @777PerfectPlayer777 said. Are you trying to make it work on a ServerScript? If so, what are you trying to make it achieve the goal?
There are other ways to detect a Player changing Teams. Is the player Automatically Added by touching a Specific Part/Block? If so, PlayerAdded other than GetPropertyChangedSignal could work.
It works fine for me regardless of where the script is. The only thing I can think of is that you’re looking for a team change that occurs before the script loads? A script in StarterPlayerScripts will load nearly instantly where a script in a StarterGui will take some extra time to load in for various potential reasons.
Like what @MightyDantheman said, its probably because the player’s team has already changed by the time the script in StarterGui has loaded.
This is because scripts in StarterPlayerScripts are copied into the player and ran when the player joins the server, while the contents of StarterGui are copied into the character when the player’s character loads, which can be some time later.
If you need to handle the player’s team on startup, you should create a function that is called when the signal changes and immediately upon startup.
local function LocalTeamChanged()
-- do something
end
LocalPlayer:GetPropertyChangedSignal("Team"):Connect(LocalTeamChanged)
LocalTeamChanged()
Dude, it’s the first 3 letters of my post. “Done on client” CLIENT!
I’m trying to detect if the player changed teams.
The player’s team changes after 15 seconds, so that can’t be it. (The gui is loaded before the player changes teams)