Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Disable forward and backwards keys?

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!

7 comments

0

Try unbinding the keys. I could list the wiki link?

0

Could you? that would be great!

0

I tried using the code from here: https://scriptinghelpers.org/questions/6792/unbinding-keysunanswered but it didn't work

0

I know it does not. But the wiki article can teach better.

0

Whats the wiki article? I can't seem to find it

0

I'll post a comment 1 second.

2 answers

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.

4 comments

0

@CodeTheorem, That just disabled the character, You can just disable the Humanoid not everything..

0

How so?

0

I'll show you, posting an answer. Wait a second or two?

0

Still no answer from you... :/

I don't know but maybe maybe maybe you can try using the .Disabled if the key has a disabled propertie again just maybe.

This discussion is preserved as it was. New answers, comments, and votes are closed.