Fly Tool Mobile Support Help 2

is there a way to make this fly script support on mobile?

script:

local tool = script.Parent
local Handle = tool:WaitForChild("Handle")

local flying = false

tool.Activated:Connect(function()
    flying = true
    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/100,math.huge/100,math.huge/100)
    while flying do
        velocity.Velocity = mouse.Hit.LookVector*100
        tool.Deactivated:Connect(function()
            flying = false
        end)
        wait()
    end
end)
tool.Deactivated:Connect(function()
    flying = false
    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)

this is not mine anyways

1 Like
local u: UserInputService = game:GetService("UserInputService")
local tool = script.Parent
local Handle = tool:WaitForChild("Handle")

local flying = false

local function stop()
	flying = false
	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

local s = false
tool.Equipped:Connect(function()
	s = true
end)
tool.Unequipped:Connect(function()
	s = false
	stop()
end)
u.InputBegan:Connect(function(input, g)
	if s and not g and (input.UserInputType == Enum.UserInputType.Touch or input.UserInputType == Enum.UserInputType.MouseButton1) then
		flying = true
		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/100,math.huge/100,math.huge/100)
		while flying do
			velocity.Velocity = mouse.Hit.LookVector*100

			tool.Deactivated:Connect(function()
				flying = false
			end)
			wait()
		end
	end
end)
u.InputEnded:Connect(function(input)
	if s and (input.UserInputType == Enum.UserInputType.Touch or input.UserInputType == Enum.UserInputType.MouseButton1) then
		stop()
	end
end)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.