So I made a localscript for a noclip tool for my game, and it fully works for PC only.
I want to rewrite my localscript so my noclip tool works on all devices. However, I do not know if that’s possible yet.
It’s not like the noclip tool is broken or works in a different way than expected, it’s like the tool doesn’t work at all on mobile and console, since it’s only scripted for PC.
I have tried to rewrite the code several times to no avail. Sometimes the new code breaks the old code for PC but works for the other devices. Simply, what I’ve tried so far didn’t help.
Below is the localscript for my noclip tool.
local tool = script.Parent
local player = game.Players.LocalPlayer
local UIS = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local noclip = false
local fly = false
local flySpeed = 50
local gui = player:WaitForChild("PlayerGui"):WaitForChild("NoclipGUI")
local label = gui:WaitForChild("NoclipLabel")
local function updateGUI()
if noclip then
label.Text = "Fly + Noclip ON | Speed: " .. flySpeed
label.TextColor3 = Color3.new(0, 1, 0)
else
label.Text = "Fly + Noclip OFF"
label.TextColor3 = Color3.new(1, 0, 0)
end
end
local function forceNoclip()
if player.Character then
for _, part in ipairs(player.Character:GetDescendants()) do
if part:IsA("BasePart") then
part.CanCollide = false
end
end
end
end
local function toggle()
noclip = not noclip
fly = noclip
updateGUI()
print("Fly + Noclip toggled:", noclip)
end
tool.Activated:Connect(toggle)
UIS.InputBegan:Connect(function(input, gpe)
if gpe then return end
if input.KeyCode == Enum.KeyCode.N then
toggle()
end
if input.KeyCode == Enum.KeyCode.E and fly then
flySpeed = flySpeed + 10
updateGUI()
print("Speed increased to", flySpeed)
end
if input.KeyCode == Enum.KeyCode.Q and fly then
flySpeed = math.max(5, flySpeed - 10)
updateGUI()
print("Speed decreased to", flySpeed)
end
end)
RunService.RenderStepped:Connect(function()
if fly and player.Character then
forceNoclip()
local char = player.Character
local hrp = char:FindFirstChild("HumanoidRootPart")
local hum = char:FindFirstChildWhichIsA("Humanoid")
if hum then hum.PlatformStand = true end
if not hrp then return end
local move = Vector3.zero
if UIS:IsKeyDown(Enum.KeyCode.W) then
move = move + workspace.CurrentCamera.CFrame.LookVector
end
if UIS:IsKeyDown(Enum.KeyCode.S) then
move = move - workspace.CurrentCamera.CFrame.LookVector
end
if UIS:IsKeyDown(Enum.KeyCode.A) then
move = move - workspace.CurrentCamera.CFrame.RightVector
end
if UIS:IsKeyDown(Enum.KeyCode.D) then
move = move + workspace.CurrentCamera.CFrame.RightVector
end
if UIS:IsKeyDown(Enum.KeyCode.Space) then
move = move + Vector3.new(0, 1, 0)
end
if UIS:IsKeyDown(Enum.KeyCode.LeftControl) then
move = move - Vector3.new(0, 1, 0)
end
if move.Magnitude > 0 then
hrp.Velocity = move.Unit * flySpeed
else
hrp.Velocity = Vector3.new(0, 0, 0)
end
else
if player.Character then
local hum = player.Character:FindFirstChildWhichIsA("Humanoid")
if hum then hum.PlatformStand = false end
end
end
end)
player.CharacterAdded:Connect(function()
wait(0.3)
if noclip then
updateGUI()
end
end)
I do not wish for anyone to rewrite the code in the replies, but I would rather if someone would simply tell me if it’s possible to rewrite this.