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)
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.
The input is the first parameter. Replace line 12
if IsTyping.KeyCode == Enum.KeyCode.X and DB == false then