UserInputService not working

Is there a reason this is not working? There’s no error or anything. Also it’s not printing bruh.
thanks.

local UIS = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
local Character = Player:WaitForChild("Character")
local Humanoid = Character:WaitForChild("Humanoid")
local Animation = game:GetService("ReplicatedStorage"):WaitForChild("Animations").punch


UIS.InputBegan:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		print("Bruh")
		local Track = Humanoid:LoadAnimation(Animation)
		Track:Play()
	end
end)

Try seeing if it will work if you change the if statement to

if input.KeyCode == Enum.KeyCode.E then

also doesn’t work ;-; and there’s no errors.

Then I think its cause you are running the code on the server or you are running it on the client where the client cant run, say workspace or server script service

Is all your wait for child stuff actually valid? It might be stuck on an invalid WaitForChild() statement, and never get to bind the InputBegan function, Do you get any warnings that are like Infinite yield avalaible on this waitforchild line?

1 Like

ahh I see it, Its your player line, dont do Player:WaitForChild(“Character”)

just do Player.Character

Thanks a lot. This was the problem.

Humanoid:LoadAnimation() is deprecated, make sure you’re using the Animator inside Humanoid instead.