Hello! i have this script, and it works amazingly fine on PC, but on mobile however, you cant move with the joystick and there are no errors at all. I am not sure how to really sure how to fix this at all, so help is very much appreciated, thanks!
here is the script for mobile flying, if it matters the PC flying script is binded to F but i made sure to remove that in the mobile version of it.
local UIS = game:GetService('UserInputService')
task.wait(0.5)
if script.Parent.Parent["Run button"].Visible == true then
script.Parent.Visible = true
else
script.Parent.Visible = false
end
local HoverAnimID = "rbxassetid://17402721184"
local FlyAnimID = "rbxassetid://17402055688"
local FlylAnimID = "rbxassetid://17402082521"
local FlyrAnimID = "rbxassetid://17402066227"
local BodyVelocity = script:WaitForChild("BodyVelocity"):Clone()
local v3 = script.BodyGyro:Clone()
local Player = game.Players.LocalPlayer
local Character = Player.Character
local Humanoid = Character:FindFirstChild("Humanoid") or Character:WaitForChild("Humanoid")
BodyVelocity.Parent = Character
v3.Parent = Character
local Hover = Instance.new("Animation")
Hover.AnimationId = HoverAnimID
local Fly = Instance.new("Animation")
Fly.AnimationId = FlyAnimID
local FlyR = Instance.new("Animation")
FlyR.AnimationId = FlyrAnimID
local FlyL = Instance.new("Animation")
FlyL.AnimationId = FlylAnimID
local canfly = Character:WaitForChild("Flight")
canfly.Value = false
local wings = canfly:WaitForChild("Wings")
wings.Value = false
local v10 = Humanoid.Animator:LoadAnimation(Hover)
local v11 = Humanoid.Animator:LoadAnimation(Fly)
local v12 = Humanoid.Animator:LoadAnimation(FlyL)
local v13 = Humanoid.Animator:LoadAnimation(FlyR)
local Camera = game.Workspace.Camera
local function u2()
if Humanoid.MoveDirection == Vector3.new(0, 0, 0) then
return Humanoid.MoveDirection
end
local v14 = (Camera.CFrame * CFrame.new((CFrame.new(Camera.CFrame.p, Camera.CFrame.p + Vector3.new(Camera.CFrame.lookVector.x, 0, Camera.CFrame.lookVector.z)):VectorToObjectSpace(Humanoid.MoveDirection)))).p - Camera.CFrame.p;
if v14 == Vector3.new() then
return v14
end
return v14.unit
end
local Flymoving = script.Flymoving
local TweenService = game:GetService("TweenService")
local Flying = false
game:GetService("RunService").RenderStepped:Connect(function()
if script.Parent == Character then
if canfly.Value == true then
if Flying == true then
Humanoid:ChangeState(6)
v3.CFrame = game.Workspace.Camera.CFrame
if u2() == Vector3.new(0, 0, 0) then
Flymoving.Value = false
else
Flymoving.Value = true
end
TweenService:Create(BodyVelocity, TweenInfo.new(0.3), {Velocity = u2() * 100}):Play()
end
elseif canfly == false then return end
end
end)
Flymoving.Changed:Connect(function(p1)
if p1 == true then
v10:Stop()
v11:Play()
return
end
if p1 == false then
v11:Stop()
v10:Play()
end
end)
local xractivated = false
script.Parent.MouseButton1Click:Connect(function()
if canfly.Value == true then
if wings.Value == true then
if Flying == false then
Flying = true
if Character:FindFirstChild("HumanoidRootPart") then
v10:Play(0.1, 1, 1)
Character.HumanoidRootPart.Running.Volume = 0
BodyVelocity.Parent = Character.HumanoidRootPart
v3.Parent = Character.HumanoidRootPart
end
else
Flying = false
Flymoving.Value = false
v12:Stop()
v13:Stop()
v10:Stop()
v11:Stop()
Character.HumanoidRootPart.Running.Volume = 0.65
Humanoid:ChangeState(8)
BodyVelocity.Parent = Character
v3.Parent = Character
end
elseif wings.Value == false then return end
elseif canfly.Value == false then return end
end)
canfly:GetPropertyChangedSignal("Value"):Connect(function()
if canfly.Value == false then
Flying = false
Flymoving.Value = false
v12:Stop()
v13:Stop()
v10:Stop()
v11:Stop()
Character.HumanoidRootPart.Running.Volume = 0.45
Humanoid:ChangeState(8)
BodyVelocity.Parent = Character
v3.Parent = Character
end
end)
wings:GetPropertyChangedSignal("Value"):Connect(function()
if wings.Value == false then
Flying = false
Flymoving.Value = false
v12:Stop()
v13:Stop()
v10:Stop()
v11:Stop()
Character.HumanoidRootPart.Running.Volume = 0.45
Humanoid:ChangeState(8)
BodyVelocity.Parent = Character
v3.Parent = Character
end
end)