I’m a bit confused on the math and I can’t really find something that answers my question specifically, I have a part positioned on the map, and I want the player to get flung in the direction of that part upon touching another part, basically a jump pad.
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if hit.Parent.HumanoidRootPart:FindFirstChild("BodyVelocity") then
return
end
local bodyVelocity = Instance.new("BodyVelocity")
bodyVelocity.Parent = hit.Parent.HumanoidRootPart
local direction = (workspace.DirectionalPart.Position - hit.Parent.HumanoidRootPart.Position).Unit
bodyVelocity.MaxForce = Vector3.new(50000, 50000, 50000)
bodyVelocity.Velocity = (hit.Parent.HumanoidRootPart.Position + direction) * 20
end
end)