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!)
thanks!!