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

How to stop UserInput executing in chat?

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

✓ Accepted answer

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

2 comments

0

yeah

0

Thanks a lot! This helped a lot man! That stupid chat issue I was dealing with.

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