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

HOW TO MAKE IT SO PRESSING A BUTTON WHILE TYPING DOESNT ACTIVATE SCRIPT?

I want to make it so that when you press R while typing, the run script does not activate.

local Player = game.Players.LocalPlayer
local mouse = Player:GetMouse()
local origSpeed = 16
local character = Player.Character
local humanoid = character.Humanoid
	
game:GetService('UserInputService').InputBegan:Connect(function(input, process)
	   if input.UserInputType == Enum.UserInputType.Keyboard then
	       if input.KeyCode == Enum.KeyCode.R and Player and character and humanoid.WalkSpeed == origSpeed  then
	    Player.Character.RUNSCRIPT.SPEED.Disabled = false
Player.Character.Anima.Disabled = true
Player.Character.RUNANIMATION.Disabled = false
	
		elseif input.KeyCode == Enum.KeyCode.R and humanoid.WalkSpeed == Player.Character.RUNSCRIPT.RunSpeed.Value then
	     humanoid.WalkSpeed = origSpeed
	   Player.Character.RUNSCRIPT.SPEED.Disabled = true
	Player.Character.RUNANIMATION.Disabled = true
Player.Character.Anima.Disabled = false
		end
	end
	end)

1 comment

0

In your line 8, put 'and not process' after .Keyboard

1 answer

✓ Accepted answer

###Make line 8 like this.

if input.UserInputType == Enum.UserInputType.Keyboard and not process then

3 comments

0

The second parameter doesn't actually check if they are typing, however, that is one reason it may be true. Use GetFocusedTextBox.

0

Thanks! It works now :)

0

^^ The second prometer checks if the typing is being processed elsewhere. True if so.

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