User Input not working on push up mat

I’m trying to make a script that lets players do a push up on a mat when they press on the proximity prompt, but for some reason the user input service isnt working on the script. The player doesnt stop the idle animation when jumped, and doesn’t do the action animation when left mouse is clicked.

Server script

local storage = game.ReplicatedStorage
local prompt = script.Parent.ProximityPrompt
local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://14842281716"
local anim2 = Instance.new("Animation")
anim2.AnimationId = ("rbxassetid://14842244544")

prompt.Triggered:Connect(function(player)
	wait()
	storage["Push Up"]:FireClient(player)
	
	local hum = player.Character:WaitForChild("Humanoid")

	hum.WalkSpeed = 0
	player.Character.HumanoidRootPart.CFrame = game.Workspace["Push Up mat"].CFrame

	local loadAnim = hum.Animator:LoadAnimation(anim)
	local loadAnim2 = hum.Animator:LoadAnimation(anim2)
	loadAnim:play() 
end)

Client Script

local UserInputService = game:GetService("UserInputService")
local prompt = script.Parent.ProximityPrompt


local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://14842281716"
local anim2 = Instance.new("Animation")
anim2.AnimationId = ("rbxassetid://14842244544")

local storage = game.ReplicatedStorage
local event = storage["Push Up"]

storage["Push Up"].OnClientEvent:Connect(function(player)

print("Push Up!")
	
	wait(1)
	
	local hum = player.Character:WaitForChild("Humanoid")

	local loadAnim = hum.Animator:LoadAnimation(anim)
	local loadAnim2 = hum.Animator:LoadAnimation(anim2)


	UserInputService.InputBegan:Connect(function(inputObject)
		if inputObject.UserInputType == Enum.UserInputType.MouseButton1 then
			loadAnim:stop()
			loadAnim2:play()
			print("Down")

		elseif inputObject.UserInputType == Enum.KeyCode.Space then
			loadAnim:stop()

		end
	end)





end)

How about not allowing jumping by setting humanoid JumpPower/Height to 0

Who the heck jumps during a pushup?

Also, try using mouse.button1down instead, idk, that worked better for me

1 Like

As suggested above, you should either change the player’s jump height/power or disable the jumping state with Humanoid:SetStateEnabled(). The animation might not be playing because the core jump animation could be perhaps overriding its priority.

It has come to my attention that your remote event request may not be being received on the client. Make sure that the event has loaded before your script and confirm that it is working. I suggest that you review the error that is currently in your output and confirm that it is not the same script.

2 Likes

The jump is there so that the player stops doing pushups.

I think the problem is the remote event. Theres no errors in my output, but nothing in the client script happens.

Then why do you care if the default animation plays when jumping then

And I think you are right about it being the remote, I think you can only detect user input on the client.

You should adjust the AnimationPriority such that when you hit jump or move, the animation immediately stops; you don’t need to use any UIS to detect jump; it works on its own.
Check the following; AnimationPriority | Roblox Creator Hub Documentation

You must change the Animation’s AnimationPriority.

1 Like

The

is there so the player stops doing the pushup animation when jumped