Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

Disable forward and backwards keys?

Asked by
Bman8765 270 Moderation Voter
10 years ago

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!

0
Try unbinding the keys. I could list the wiki link? HexC3D 830 — 10y
0
Could you? that would be great! Bman8765 270 — 10y
0
I tried using the code from here: https://scriptinghelpers.org/questions/6792/unbinding-keysunanswered but it didn't work Bman8765 270 — 10y
0
I know it does not. But the wiki article can teach better. HexC3D 830 — 10y
View all comments (3 more)
0
Whats the wiki article? I can't seem to find it Bman8765 270 — 10y
0
I'll post a comment 1 second. HexC3D 830 — 10y

2 answers

Log in to vote
0
Answered by 10 years ago

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.

0
@CodeTheorem, That just disabled the character, You can just disable the Humanoid not everything.. HexC3D 830 — 10y
0
How so? NoahWillCode 370 — 10y
0
I'll show you, posting an answer. Wait a second or two? HexC3D 830 — 10y
0
Still no answer from you... :/ NoahWillCode 370 — 10y
Ad
Log in to vote
-2
Answered by 10 years ago

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

Answer this question