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

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

Asked by 10 years ago

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

0
how do you do this? qazer1234 0 — 10y

1 answer

Log in to vote
1
Answered by
HexC3D 830 Moderation Voter
10 years ago

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.

Ad

Answer this question