UserInputService still firing when typing in chat

Whenever someone types the key “r”, in the chat or not, it will always result in the code firing. Help.

UIS.InputBegan:Connect(function(input, gameProcessedEvent)
	if input.KeyCode == Enum.KeyCode.R then
		if stand == true then
			rep.Events.InputEvent:FireServer("Ragdoll")
			stand = false
			
		elseif stand == false then
			rep.Events.InputEvent:FireServer("Stand")
			stand = true
		end
	end
	
	if input.KeyCode == Enum.KeyCode.E then
		if stand == false then return end
		if mouse.Target then
			if mouse.Target.Anchored == false then
				selectedPart = mouse.Target
				
				mouse.TargetFilter = selectedPart
				local bodyPosition = Instance.new("BodyPosition")
				bodyPosition.Parent = selectedPart
				rep.Events.OwnershipEvent:FireServer(selectedPart, "Add")
			end
		end
	end
end)

if gameProcessedEvent then return end

1 Like

That second argument you have passed under the actual key function is basically the solution you’re looking for

Typing falls under the category of gameProcessedEvent

so to simply fix it you can add a conditional statement to check if there isn’t any ‘GameEvents’ running(such as typing.)

if gameProcessedEvent then return end
1 Like