Team property changing twice

using getpropertychangedsignal to detect when the players team changes makes it fire twice

for example, someone is on team A and they switch to team B.

Player:GetPropertyChangedSignal('Team'):Connect(function() --runs twice cuz it removes a team and changesit

	if Player.Team == Teams:WaitForChild("teamA") then
    end

	if Player.Team == Teams:WaitForChild("teamB") then
--this fires twice
    end
2 Likes

Where did you put your script and which kind of script did you use? ( Also it seems to work fine for me )

2 Likes

I don’t really see how this is an issue since you are doing only checks inside the function which isn’t affected upon the function firing multiple times.

1 Like

local script in startercharacter
i have a round system that will choose a role for the player when the round starts

Player:GetPropertyChangedSignal('Team'):Connect(function() 
	print('teamchanged')
	if Player.Team == Teams:WaitForChild("ppl") then
		ActivateScripts("Survivor")
	elseif Player.Team == Teams:WaitForChild("mmmonster") then
		ActivateScripts("Monster")
	elseif Player.Team == Teams:WaitForChild("spectators") then
		ActivateScripts("Spectator")
	end
end)

the ActivateScripts() function runs twice which is the problem, and its not a problem with the function; if i remove the function and just put a print() it will still print twice

1 Like