Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

how do you make the player's health go down when a platform touches them?

when a part touches it what method do you use? please help!

1 comment

0

how do you do this?

1 answer

✓ Accepted answer

TakeDamage()

Using the the take damage method can subtract health when you touch a platform something like this.

script.Parent.Touched:connect(function(hitPart)
local player = game.Players:GetPlayerFromCharacter(hitPart.Parent)
if player then
for i, part  in pairs(player.Character:GetChildren()) do
if part:IsA("Humanoid") then
part:TakeDamage(10)
end
end
end)

Then the player would take 10 damage on the health it is a bit more efficient then just subtracting it.

TakeDamage(-10)

In this case it would add 10 health.

This discussion is preserved as it was. New answers, comments, and votes are closed.