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

How to stop UserInput executing in chat?

Asked by 6 years ago

So I've been trying to make it where my UserInputService (InputBegan & InputEnded) doesn't execute in chat. Whenever I have a keycode set to lets say X right. And at the input began it will print out "hi", at the input ended it will print out "bye". Simple right. Well if you actually go into the chat and press the letter, it executes the userinput. This is my code

game:GetService("UserInputService").InputBegan:Connect(function(KeyDown)
    if KeyDown.KeyCode == Enum.KeyCode.LeftShift then
        game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 32
    end
end)

game:GetService("UserInputService").InputEnded:Connect(function(KeyDown)
    if KeyDown.KeyCode == Enum.KeyCode.LeftShift then
        game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 16
    end
end)

I really don't know how to solve this, I've been trying to look online and everywhere but I can't seem to fix the problem. (This code will also be executed in the chat if you press LeftShift, please help me to solve this chat with UserInput problem).

1 answer

Log in to vote
2
Answered by
xEiffel 280 Moderation Voter
6 years ago
Edited 6 years ago

Hey, there is a second function variable that stops this, here is the example:

game:GetService("UserInputService").InputBegan:Connect(function(KeyDown, gameProcessed)
    if not gameProcessed then
     if KeyDown.KeyCode == Enum.KeyCode.LeftShift then
            game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 32
     end
    end
end)

game:GetService("UserInputService").InputEnded:Connect(function(KeyDown, gameProcessed)
    if not gameProcessed then
     if KeyDown.KeyCode == Enum.KeyCode.LeftShift then
            game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 16
     end
    end
end)

This basically stops all game events by Roblox from being fired

0
yeah User#19524 175 — 6y
0
Thanks a lot! This helped a lot man! That stupid chat issue I was dealing with. User#21998 0 — 6y
Ad

Answer this question