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

[SOVLED] | Keyboard Input help?

Asked by 8 years ago

I've been trying to activate a remote function on a key press and it worked in studio, but when I joined the game, it didn't work.

So I tried to narrow down the possibilities of what it could be: I started off by Re-Writing the code (this time using ContextActionService instead of UserInputService), and it still didn't work, so I tried changing the players walk speed (instead of firing a remote function) and again, it worked in studio, but not in the player.

I'm not very adept at scripting (I'm just starting out ;P) so I don't know what the problem with it is. Here is my code:

local showDialog = game.ReplicatedStorage.ShowDialog

-- Will be used for the remote function later

isInRange = true


function sendSignInfo(actionName, userInputState, inputObject)
    if isInRange == true and userInputState == Enum.UserInputState.Begin then
        print("test")
        game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 100
    end
end


game.ContextActionService:BindAction("keyPress", sendSignInfo, false, Enum.KeyCode.E)

Send help if you know what the problem is!

Thanks, Kyleo.

0
Some of the spacing is messed up from the post, I do (think) I have it formatted correctly. Also there are no errors in the output. ;P Kyleocraft 25 — 8y
0
Is this in a LocalScript? ItsMeKlc 235 — 8y
0
No, regular script in an object, should it be in StarterPlayerScripts? Kyleocraft 25 — 8y
0
PlayerGui or Backpack would do fine ItsMeKlc 235 — 8y

1 answer

Log in to vote
0
Answered by
ItsMeKlc 235 Moderation Voter
8 years ago

Any scripts that deal with anything client side, like userImputService, must be in a LocalScript. Also from now on please use the a code block for your code (The little blue circle with "Lua" on it)

0
Thanks! I should have guessed that it needed to be in a local script! ;P Kyleocraft 25 — 8y
Ad

Answer this question