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

How do I track velocity?

Asked by 8 years ago

How do I measure velocity so that when it exceeds a certain velocity, the sword tool does damage? I thought about doing something like

if part.Velocity < Vector3(10,0,0) then
    --damage script here
end

until I found out that velocity doesn't work too well with humanoids.

1 answer

Log in to vote
0
Answered by 8 years ago
local Sword = script. Parent
local speedLimit = 30
local dmg
Sword.Blade.Touched: connect (function (part)
if part.Parent:FindFirstChild("Humanoid") then 
dmg = ((part.Velocity.magnitude > speedLimit ) and (20 + (speedLimit/2) or 20)
part.Parent.Humanoid: TakeDamage(dmg)
end
end)

Ad

Answer this question