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)