
Key Required

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



how to use this script?
How it work?