Hello,
I want to make a tool that when you hold click it will fly you in the direction you are facing. I have a script that kind of works, except that you need to let go of the mouse to fly in another direction. Does anyone know how to fix this?
Here is the localscript:
local tool = script.Parent
local Handle = tool:WaitForChild("Handle")
tool.Activated:Connect(function()
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local character = player.Character or player.CharacterAdded:Wait()
local hrp = character:WaitForChild("HumanoidRootPart")
local velocity = Instance.new("BodyVelocity", hrp)
velocity.MaxForce = Vector3.new(math.huge/2,math.huge/2,math.huge/2)
velocity.Velocity = mouse.Hit.LookVector*100
end)
tool.Deactivated:Connect(function()
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local hrp = character:WaitForChild("HumanoidRootPart")
local children = hrp:GetChildren()
for i = 1, #children do
local child = children[i]
if child:IsA("BodyVelocity") then
child:Destroy()
end
end
end)
Thank you!!

1 comment
Script.parent.local