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

UserInputService not working. No errors? [Solved]

I tried to make a script that allowed the user to use a dash like ability but the UserInputService wouldn't detect when someone pressed a key. Can anyone Help? This is my code:

local Remote = script:WaitForChild("Remote")
local UIS = game:GetService("UserInputService")


local DB = false
local Cooldown = 10


UIS.InputBegan:Connect(function(IsTyping, Input)
	if script.Parent.Equipped == true then
		if IsTyping then return end
		if Input.KeyCode == Enum.KeyCode.X and DB == false then
			DB = true
			Remote:FireServer()
			print('Fired')
		end
	else return 
	end
end)


Remote.OnClientEvent:Connect(function()
	wait(Cooldown)
	DB = false
	
end)

This is what I have on the other script which detects if the remote is fired .

local Remote = script.Parent

Remote.OnServerEvent:Connect(function(player)
	
	
	
	
end)


2 answers

✓ Accepted answer

The arguments of the InputBegan event are as follows: Instance input, bool gameProcessedEvent. There is no argument passed by InputBegan that indicate whether the client was typing. If you wish to excecute any function upon key press when client is not typing, I strongly recommend ContextActionService:BindFunction(). If you still want to use UIS, just remove the "IsTyping" argumennt you included in the event.

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