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

help with Torso Velocity's magnitude which is killing player?

Asked by
yoshi8080 445 Moderation Voter
8 years ago

No errors, just need help to prevent player's death if player's velocity is 0

script.Parent.Touched:connect(function(p)
local hum = p.Parent:FindFirstChild('Humanoid')
if (hum ~= nil) and p.Parent.Torso.Velocity.magnitude > 0 then
hum.Health = 0
elseif hum ~= nil and p.Parent.Torso.Velocity.magnitude < 0 then
print('Safe')
end
end)

1 answer

Log in to vote
1
Answered by 8 years ago

So your code is well, but its one issue. A character's Torso never has the velocity of 0 in any of its values. Due to roblox animations, or animations in general, the torso it constantly moving in some direction. Try changing the value from 0 to like .2 or .3

Ad

Answer this question