Okay, so I am trying check when a player has died and then run the code if said player has died. The loop at bottom is confirmed to work because the function runs. It gets to the second if/then statement at line 9 and then it doesn't work. The "Workspace.Game_Running" is not the broken if/then statement, it is the one below it. It goes straight down to else and prints out (The checks for TeamColor have somehow failed.) Here is the output
Player1 has died. Game is running, moving player to terminal. The checks for TeamColor have somehow failed.
I don't know why the code stops there. I have checked the Properties for players and I have confirmed that TeamColor is spelled correctly and with correct capitalization. New Yeller is also spelled correctly with correct capitalization.
local Hack = script.Parent local Y = game.workspace local Torso = script.Parent.Parent.Torso local Player = Hack.Parent.Name function OnDeath() if Workspace.Game_Running.Value == true then print("Game is running, moving player to terminal.") if game.Players:FindFirstChild("Player1").TeamColor == "NewYeller" then print('Player is Hacker, moving them to terminal H') Y.Terminal_H.Crystal.Position = Pos Torso.CFrame = CFrame.new(Vector3.new(Pos)) Torso.Anchored = true wait(30) Torso.Anchored = false Hack.Value = 10000 wait(3) Hack.Value = 100 elseif game.Players:FindFirstChild("Player1").TeamColor == "Cyan" then print('Player is Security, moving them to terminal P') Y.Terminal_P.Crystal.Position = Pos Torso.CFrame = CFrame.new(Vector3.new(Pos)) Torso.Anchored = true wait(30) Torso.Anchored = false Hack.Value = 10000 wait(3) Hack.Value = 100 else print("The checks for TeamColor have somehow failed.") end elseif Workspace.Game_Running.Value == false then print("Game is not running, resetting health") Hack.Value = 100 else print("Error") end end while true do wait() if Hack.Value < 1 then print(Hack.Parent.Name .." has died") OnDeath() wait(34) end end