function module.linearVelocity(hrp, knockback, type)
local linearVelocity = Instance.new("LinearVelocity", hrp)
linearVelocity.Attachment0 = hrp:WaitForChild("RootAttachment")
linearVelocity.MaxForce = 100000
linearVelocity.RelativeTo = Enum.ActuatorRelativeTo.Attachment0
if type == "enemy" then
linearVelocity.VectorVelocity = knockback
elseif type == "player" then
local trackingBox = Instance.new("Part", game.Workspace)
trackingBox.Size = Vector3.new(7,7,7)
trackingBox.CanCollide = false
trackingBox.CanQuery = false
trackingBox.CanTouch = false
trackingBox.Transparency = 0.5
trackingBox.Color = Color3.new(1, 0, 0)
trackingBox.CFrame = hrp.CFrame
trackingBox.Anchored = false
local weld = Instance.new("WeldConstraint", trackingBox)
weld.Part0 = hrp
weld.Part1 = trackingBox
linearVelocity.VectorVelocity = Vector3.new(0,0,knockback)
trackingBox.Touched:Connect(function(hit)
local hitChar = hit.Parent
if hit.Parent:FindFirstChild("Humanoid") and hit.Parent ~= hrp.Parent then
linearVelocity:Destroy()
hit.Parent.Humanoid.WalkSpeed = 0
hit.Parent.Humanoid.JumpHeight = 0
trackingBox:Destroy()
end
end)
end
Debris:AddItem(linearVelocity, 0.2)
end```
#Linear velocity doesn't work because I added a part
1 messages · Page 1 of 1 (latest)
How can I fix this? the tracking box is there to detect if a player during the dash and stun them and i needed a bigger detection area than just the hrp itself
maybe there's a more efficient way to do this?
ake the tracking box masless
ty that worked but i changed to getpartsboundinbox anyway
.touched was very inconsistent