game.Players.LocalPlayer.Character:findFirstChild("Torso")
game.Players.LocalPlayer.Character:findFirstChild("Humanoid")
local mouse = game.Players.LocalPlayer:GetMouse()
repeat wait() until mouse
local plr = game.Players.LocalPlayer
local torso = plr.Character.Torso
local root = plr.Character:WaitForChild("HumanoidRootPart")
local flying = false
local ctrl = {f = 0, b = 0, l = 0, r = 0}
local lastctrl = {f = 0, b = 0, l = 0, r = 0}
local speed = 60
local human = game.Workspace[plr.Name].Humanoid
local bg = Instance.new("BodyGyro")
bg.P = 9e4
bg.maxTorque = Vector3.new(9e9, 9e9, 9e9)
bg.cframe = torso.CFrame
game.Players.LocalPlayer.Character.HumanoidRootPart.DescendantAdded:connect(function(dec)
if dec.ClassName == "BodyGyro" and flying then
wait()
dec.Parent = game.Players.LocalPlayer
repeat wait() until not flying
if dec.Parent ~= nil then
dec.Parent = game.Players.LocalPlayer.Character.HumanoidRootPart
end
end
end)
function Fly()
local dec = game.Players.LocalPlayer.Character.HumanoidRootPart:FindFirstChild("BG")
if dec then
dec.Parent = game.Players.LocalPlayer
coroutine.resume(coroutine.create(function()
repeat wait() until not flying
if dec.Parent ~= nil then
dec.Parent = game.Players.LocalPlayer.Character.HumanoidRootPart
end
end))
end
bg.Parent = torso
local bv = Instance.new("BodyVelocity", torso)
bv.velocity = Vector3.new(0,0,0)
bv.maxForce = Vector3.new(9e9, 9e9, 9e9)
repeat wait()
plr.Character.Humanoid.PlatformStand = true
if (ctrl.l + ctrl.r) ~= 0 or (ctrl.f + ctrl.b) ~= 0 then
bv.velocity = ((game.Workspace.CurrentCamera.CoordinateFrame.lookVector * (ctrl.f+ctrl.b)) + ((game.Workspace.CurrentCamera.CoordinateFrame * CFrame.new(ctrl.l+ctrl.r,(ctrl.f+ctrl.b)*0,0).p) - game.Workspace.CurrentCamera.CoordinateFrame.p))*60
lastctrl = {f = ctrl.f, b = ctrl.b, l = ctrl.l, r = ctrl.r}
elseif (ctrl.l + ctrl.r) == 0 and (ctrl.f + ctrl.b) == 0 and speed ~= 0 then
bv.velocity = ((game.Workspace.CurrentCamera.CoordinateFrame.lookVector * (lastctrl.f+lastctrl.b)) + ((game.Workspace.CurrentCamera.CoordinateFrame * CFrame.new(lastctrl.l+lastctrl.r,(lastctrl.f+lastctrl.b)*0,0).p) - game.Workspace.CurrentCamera.CoordinateFrame.p))*0
else
bv.velocity = Vector3.new(0,0,0)
end
bg.cframe = game.Workspace.CurrentCamera.CoordinateFrame
until not flying
ctrl = {f = 0, b = 0, l = 0, r = 0}
lastctrl = {f = 0, b = 0, l = 0, r = 0}
speed = 0
bg.Parent = nil
bv:Destroy()
plr.Character.Humanoid.PlatformStand = false
end
script.Parent.MouseButton1Down:connect(function()
print("Noclipping")
if (flying == false) then
print("Starting to noclip")
flying = true
Fly()
elseif (flying == true) then
print("Stopping noclipping")
flying = false
end
end)
mouse.KeyDown:connect(function(key)
if key:lower() == "w" or human.MoveDirection.Y > 0 then
ctrl.f = 1
elseif key:lower() == "s" or human.MoveDirection.Y < 0 then
ctrl.b = -1
elseif key:lower() == "a" or human.MoveDirection.X > 0 then
ctrl.l = -1
elseif key:lower() == "d" or human.MoveDirection.X < 0 then
ctrl.r = 1
end
end)
mouse.KeyUp:connect(function(key)
if key:lower() == "w" or human.MoveDirection.Y > 0 then
ctrl.f = 0
elseif key:lower() == "s" or human.MoveDirection.Y < 0 then
ctrl.b = 0
elseif key:lower() == "a" or human.MoveDirection.X > 0 then
ctrl.l = 0
elseif key:lower() == "d" or human.MoveDirection.X < 0 then
ctrl.r = 0
end
end)
Fly()
COMMUNITY QUESTION
Why am I not able to move my character on mobile with this script?
1 answer
You need UserInputService in your life my child, also when using UserInputService remember if you're making a custom walkscript you'd need to add keycode and Touchcontrol, theres a thing on the wiki about the mobile controls.
This discussion is preserved as it was. New answers, comments, and votes are closed.

4 comments
Lots of deprecated code! Makes me wan to take your computer and rewrite your script.
Any input on what I can do to improve this?
Maybe don’t use keydown in the future, since it’s really inaccurate...
Keydown doesn't works on mobiles. So my games with keydowns will be not available to mobile and ipads..