UserInputService not working?

I’ve recently run into an issue where UserInputService does not seem to be working. At first I thought the script just weren’t loading but the new script that I made using ContextActionService (All the script were working then) is the only one that seemed to work. I even added a

print("cool")

at the top just to be sure the script loaded and it printed perfectly fine I also checked when I joined the game on both client and server and the scripts were still there with code inside.

2 Likes

Can you send us the code please so we can figure what is going on?

This does not help solve your problem. Can you send the code that you are using?

UserInputService works perfectly fine, you must have made a mistake in the code.

I did not feel it was necessary since it worked perfectly fine before but here

local uis = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")
local Debris = game:GetService("Debris")
local RE = game:GetService("ReplicatedStorage")
--local Dash = RE["Player Movement Events"].Dash
local plr = game.Players.LocalPlayer
local Camera = workspace.CurrentCamera
local FrontDash = RE.Animations.Dashing.FrontDash
local BackDash = RE.Animations.Dashing.BackDash
local RightDash = RE.Animations.Dashing.RightDash
local LeftDash = RE.Animations.Dashing.LeftDash
local Cooldowns = require(game.ReplicatedStorage.Cooldowns)
local OldView = Camera.FieldOfView


local tweenInfo = TweenInfo.new(
	1,
	Enum.EasingStyle.Quint,
	Enum.EasingDirection.Out,
	0,
	false,
	0
)

local goals = {
	FieldOfView = 85;
}

local goals2 = {
	FieldOfView = OldView;
}


uis.InputBegan:Connect(function(Input, Talking)
	if not Talking then
		if Input.KeyCode == Enum.KeyCode.Q then
			if _G.Block == false then
				wait(0.1)
				local PressedKeys = uis:GetKeysPressed()
				local Char = plr.Character
				
				local Result = Cooldowns.CheckCooldown("Movement", "Dash", plr)
				if Result == true then
					
					for i,v in pairs(PressedKeys) do
						if v.KeyCode == Enum.KeyCode.W then
							OldView = Camera.FieldOfView
							TweenService:Create(Camera,tweenInfo,goals):Play()
							
							local AnimTrack = Char.Humanoid:LoadAnimation(FrontDash)
							AnimTrack:Play()
							AnimTrack:AdjustSpeed(2)
							
							--Dash:FireServer()
							
							local BV = Instance.new("BodyVelocity")
							BV.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
							BV.Velocity = Char.HumanoidRootPart.CFrame.lookVector * 75
							BV.Parent = Char.HumanoidRootPart
							Debris:AddItem(BV, 0.2)
							
							wait(0.2)
							TweenService:Create(Camera,tweenInfo,goals2):Play()
							break
						elseif v.KeyCode == Enum.KeyCode.A then
							OldView = Camera.FieldOfView
							TweenService:Create(Camera,tweenInfo,goals):Play()
							
							local AnimTrack = Char.Humanoid:LoadAnimation(LeftDash)
							AnimTrack:Play()
							AnimTrack:AdjustSpeed(2)
							
							--Dash:FireServer()
							
							local BV = Instance.new("BodyVelocity")
							BV.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
							BV.Velocity = Char.HumanoidRootPart.CFrame.rightVector * -75
							BV.Parent = Char.HumanoidRootPart
							Debris:AddItem(BV, 0.2)
							
							wait(0.2)
							TweenService:Create(Camera,tweenInfo,goals2):Play()
							break
						elseif v.KeyCode == Enum.KeyCode.S then
							OldView = Camera.FieldOfView
							TweenService:Create(Camera,tweenInfo,goals):Play()
							
							local AnimTrack = Char.Humanoid:LoadAnimation(BackDash)
							AnimTrack:Play()
							AnimTrack:AdjustSpeed(2)

							
						--	Dash:FireServer()
							
							local BV = Instance.new("BodyVelocity")
							BV.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
							BV.Velocity = Char.HumanoidRootPart.CFrame.lookVector * -75
							BV.Parent = Char.HumanoidRootPart
							Debris:AddItem(BV, 0.2)
							
							wait(0.2)
							TweenService:Create(Camera,tweenInfo,goals2):Play()
							break
						elseif v.KeyCode == Enum.KeyCode.D then
							OldView = Camera.FieldOfView
							TweenService:Create(Camera,tweenInfo,goals):Play()
							
							local AnimTrack = Char.Humanoid:LoadAnimation(RightDash)
							AnimTrack:Play()
							AnimTrack:AdjustSpeed(2)
							
							--Dash:FireServer()
							
							local BV = Instance.new("BodyVelocity")
							BV.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
							BV.Velocity = Char.HumanoidRootPart.CFrame.rightVector * 75
							BV.Parent = Char.HumanoidRootPart
							Debris:AddItem(BV, 0.2)
							
							wait(0.2)
							TweenService:Create(Camera,tweenInfo,goals2):Play()
							break
						end
					end
				end
			end
		end
	end
end)

One of the scripts

I should also mention this is in Team Create

local UserInputService = game:GetService("UserInputService")

UserInputService.InputBegan:Connect(function(input, gameProcessed) 
    if gameProcessed then
        return
    end

    print("The", input.KeyCode, "key was pressed!")
end)

Restart Studio if the problem still perists.

Thanks for the help but I realised what happened the script locating the _G.Block was deleted I don’t know why it didn’t error

1 Like

It returns nil instead of erroring and since it’s in a if statement it acts like if nil == false then so it’s hard to notice.

1 Like

Oh that makes sense I understand why now

1 Like