Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local player = game.Players.LocalPlayer
- -- Disable the reset button
- player:SetAttribute("CanReset", false)
- -- Function to prevent death
- local function preventDeath(character)
- local humanoid = character:WaitForChild("Humanoid")
- -- Prevent the player from dying by setting their health to maximum if it drops
- humanoid:GetPropertyChangedSignal("Health"):Connect(function()
- if humanoid.Health < humanoid.MaxHealth then
- humanoid.Health = humanoid.MaxHealth
- end
- end)
- -- Optionally, you can make the humanoid invulnerable
- humanoid:SetStateEnabled(Enum.HumanoidStateType.Dead, false)
- end
- -- Connect the function to the player's character
- player.CharacterAdded:Connect(preventDeath)
- if player.Character then
- preventDeath(player.Character)
- end
Advertisement
Comments
-
- local player = game.Players.LocalPlayer
- -- Disable the reset button
- player:SetAttribute("CanReset", false)
- -- Function to prevent death
- local function preventDeath(character)
- local humanoid = character:WaitForChild("Humanoid")
- -- Prevent the player from dying by setting their health to maximum if it drops
- humanoid:GetPropertyChangedSignal("Health"):Connect(function()
- if humanoid.Health < humanoid.MaxHealth then
- humanoid.Health = humanoid.MaxHealth
- end
- end)
- -- Optionally, you can make the humanoid invulnerable
- humanoid:SetStateEnabled(Enum.HumanoidStateType.Dead, false)
- end
- -- Connect the function to the player's character
- player.CharacterAdded:Connect(preventDeath)
- if player.Character then
- preventDeath(player.Character)
- end
Add Comment
Please, Sign In to add comment
Advertisement