How would I go about disabling the users forwards and backwards keys. I needs this for my 2D game script so they can't walk off it. I know I could use invisible blocks but this just seems easier in the long wrong. I don't have it coded yet but I'll show you what I currently have. I have a Script located in the workspace with this code: game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) script.LocalScript:clone().Parent = character end) end)
And I have a localscript inside the script with this code: local target = game.Players.LocalPlayer.Character.Head local camera = workspace.CurrentCamera camera.CameraType = Enum.CameraType.Scriptable camera.CameraSubject = target local angle = 0 local go = 0
game:GetService("RunService").RenderStepped:connect(function() camera.CoordinateFrame = CFrame.new(target.Position) * CFrame.new(0, 0, 25) go = 1 end)
Like I've said before I have not coded the part that stops you from walking forwards and backwards yet, this is just a bit of the script to show you what I have already. Thanks!
One method that I propose is to disable ALL character control from the keyboard. Then, just create your own movement scripts. This will provide far more control. Here's how to disable all keyboard input on the character (From Wiki):
for _, controller in pairs(game:GetService("ControllerService"):GetChildren()) do controller.Parent = nil end
Put that in a LocalScript
For the article I got that loop from, click here.
I don't know but maybe maybe maybe you can try using the .Disabled if the key has a disabled propertie again just maybe.