Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make a player unable to take damage?

Asked by 4 years ago

So Ive been searching the web for about half an hour and I cant seem to find anything. I was wondeing if anyone knew how to enable and disable immortality?

2 answers

Log in to vote
0
Answered by
Necro_las 412 Moderation Voter
4 years ago
Edited 4 years ago

Have you tried force shield?

https://developer.roblox.com/en-us/api-reference/class/ForceField

Or try locking the health value in a variable and when health changes, turn the health to that value again (and disable death).

0
Another way to do this is to set the maxhealth and health to math.huge mixgingengerina10 223 — 4y
Ad
Log in to vote
0
Answered by
SirGamezy 186
4 years ago
Edited 4 years ago

Try using the Changed event:

local immortalityEnabled = true

game.Players.PlayerAdded:Connect(function(player)
    local CharHumanoid = player.Character
    if immortalityEnabled then
        CarHumanoid.Changed:Connect(function(property)
            if property == "Health" then
                CharHumanoid.Health = 100
            end
        end 
    end)
end)

I hope this helps!

0
If it doesn't work, try using a 'while' loop. SirGamezy 186 — 4y

Answer this question