This is supposed to check the health of a humanoid until it is equal to zero, then it changes the player to a different team. The loop doesn't seem to be firing. Is there something I am doing wrong? Thank you! :)
local player = game.Players.LocalPlayer local name = game.Players.LocalPlayer.Name local gethumanoid = game.workspace.name.FindFirstChild("Humanoid") repeat print ("Player is healthy") wait (1) until gethumanoid.Health == 0 player.TeamColor = BrickColor.new("Dark stone grey")
I've added a function to make the script run when triggered.
wait(1) local player= game:GetService("Players").LocalPlayer local character= player.Character local humanoid= character.Humanoid function health() if humanoid.Health ~= 0 then print("Human is healthy") elseif humanoid.Health <= 0 then print("Human is ready for organ harversting") -- This was just a joke player.TeamColor = BrickColor.new("Dark stone grey") end end humanoid.HealthChanged:connect(health) -- If the players health is changed it will trigger the function health()
If you want to keep using your old script I've fixed it below. BUT BE AWARE, IT MAY CAUSE LAG BECAUSE ITS CONSTANTLY RUNNING.
wait(1) local player = game.Players.LocalPlayer local name = game.Players.LocalPlayer.Name local gethumanoid = game.workspace[name]:FindFirstChild("Humanoid") repeat print ("Player is healthy") wait (1) until gethumanoid.Health == 0 player.TeamColor = BrickColor.new("Dark stone grey")