Script grabbing old variable's values from player

For some reason, my script keeps getting old values from variables.
Say, if a player was team blue, it would run the team blue function, but if they became team red, it would still run the team blue code, if that makes sense.
However, in this case, my prop hunt game thinks Seekers that were Hiders are still seekers, running the Hider code rather than the Seeker code.
I have been stumped on this, and any help would go greatly appreciated.

local propTransform = game.ReplicatedFirst.Props:FindFirstChild(script.Parent.Parent.Name)
local clickDetector = Instance.new("ClickDetector", script.Parent)
clickDetector.CursorIcon = "rbxasset://textures/Cursors/ArrowCursor.png"
clickDetector.MaxActivationDistance = 16



clickDetector.MouseClick:connect(function(player)
	print(tostring(player.Team))
	if tostring(player.Team) == "Hider" then
		local oldPlayer = player.Character
		local newPlayer = propTransform:Clone()

		local oldCFrame = oldPlayer:GetPrimaryPartCFrame()

		player.Character = newPlayer
		newPlayer.Parent = workspace
		newPlayer:SetPrimaryPartCFrame(oldCFrame)
		oldPlayer:Destroy()
	else
		player.Character.Humanoid.Health = player.Character.Humanoid.Health - 10
	end
	
	
end)

Appreciate it, thanks! (Also if my code looks sloppy I am very sorry, as I haven’t been able to refine it. Any help on that would also be helpful, as well as any others ways to execute the same code!)

what do you get when you used print(tostring(player.Team))?

what does it print when you’re the seeker who was a hider in the previous round?

I always get the one that I was originally.

Are you sure your team is changed? Did you change it from the client or server? (If you don’t know what I mean tell me)

1 Like

Wow, okay, thanks! So changing it via script works, however with Properties it doesn’t work (both client and server.) Thanks for the help!

No problem. So is it working now? If it is then you can set my post as solution :slight_smile: thanks!!