Hello. I’ve started making a 2D game but i can’t find anywhere how can i give it mobile support (if you play on mobile you can still go forward and backward) and fix this weird glitch:
The script is:
local camera = game.Workspace.CurrentCamera
local contextActionService = game:GetService("ContextActionService")
local userInputService = game:GetService("UserInputService")
local runService = game:GetService("RunService")
local character = script.Parent
local rootPart = character:WaitForChild("HumanoidRootPart")
local humanoid = character:WaitForChild("Humanoid")
runService.RenderStepped:Connect(function()
contextActionService:UnbindAction("moveForwardAction")
contextActionService:UnbindAction("moveBackwardAction")
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = CFrame.new(rootPart.Position.X, rootPart.Position.Y + 1, rootPart.Position.Z + 15)
end)
userInputService.InputBegan:Connect(function(input, isTyping)
if isTyping then return end
if input.KeyCode == Enum.KeyCode.A then
rootPart.CFrame = CFrame.new(rootPart.Position, Vector3.new(-90, 0, 0))
elseif input.KeyCode == Enum.KeyCode.D then
rootPart.CFrame = CFrame.new(rootPart.Position, Vector3.new(90, 0, 0))
end
end)
I would be really happy if someone can help me fix this:)