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

How do I track velocity?

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

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)

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