RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"Write me a script that makes the player invulnerable for a duration of time"
-- local script local player = game.Players.LocalPlayer local character = player.Character or player.CharacterAdded:Wait() local humanoid = character:WaitForChild("Humanoid") local invulnerable = false local invulnerabilityDuration = 10 -- Change this value to the desired duration local function makeInvulnerable() if not invulnerable then invulnerable = true humanoid.MaxHealth = math.huge humanoid.Health = math.huge wait(invulnerabilityDuration) humanoid.MaxHealth = 100 humanoid.Health = 100 invulnerable = false end end -- Call the makeInvulnerable function when needed, for example when a GUI button is pressed or an event is triggered. -- makeInvulnerable()