local Player = game.Players.LocalPlayer local RepStorage = game:GetService("ReplicatedStorage") local Remote = RepStorage:WaitForChild("DeathRemote") local function FireRemote() Remote:FireServer() end while true do wait(1) if game.Players.LocalPlayer.Character.Humanoid.Health <= 0 then FireRemote() end end -- how i wanted to fix it Player.Character.Humanoid.Health.Changed:Connect(function() print("Health Changed!") end)
So this runs a loop every second to check if a player has died this can cause lag , I already have experienced lag currently im doing some lag work for my game can someone help me?
Humanoid.Health is a property of
Humanoid and it has no
So you may change it to:
local hum = Player.Character.Humanoid local previousHealth = hum.Health hum.Changed:Connect(function() if previousHealth ~= hum.Health then print("Changed health!") previousHealth = hum.Health --fire remote as what you wanted if hum.Health <= 0 then FireRemote() end end end)
And fire some remotes...