My animation isn't working (Solved)

Okay so I have an animation but it doesn’t play for some reason. The “print(“Animation Playing”)” works but the animation doesn’t plays. I published the game and tried joining the game and seeing if it was a studio bug but it doesn’t work either.

local RemoteEvent = game.ReplicatedStorage.BestLawyer

RemoteEvent.OnServerEvent:Connect(function(player, Key)
	if Key == "Z" then
		print("Animation Playing")
		local Animation = game.ReplicatedStorage.DeskSlam
		local AnimTrack = player.Character:WaitForChild("Humanoid"):WaitForChild("Animator"):LoadAnimation(Animation)
		AnimTrack:Play()
	end
end)

Where is this remote being fired from?
Can you show what the script firing it is doing?

Try moving the print statement outside of the if Key == "Z" and see if it prints then.

It prins both

local RemoteEvent = game.ReplicatedStorage.BestLawyer

RemoteEvent.OnServerEvent:Connect(function(player, Key)
	print("Pressed key")
	if Key == "Z" then
		print("Animation Playing")
		local Animation = game.ReplicatedStorage.DeskSlam
		local AnimTrack = player.Character:WaitForChild("Humanoid"):WaitForChild("Animator"):LoadAnimation(Animation)
		AnimTrack:Play()
	end
end)

Btw this is the local script that is firing the event.

local UserInputService = game:GetService("UserInputService")
local player = game.Players.LocalPlayer

local debounce = false
local RemoteEvent = game.ReplicatedStorage.BestLawyer

UserInputService.InputBegan:Connect(function(input)
	if debounce == false then
		if input.KeyCode == Enum.KeyCode.Z then
			debounce = true
			RemoteEvent:FireServer("Z")
		end
	end
end)

maybe try :WaitForChild("DeskSlam")? Idk. I think you should put a print statement after the variables are defined in the serverScript another after the animation is supposed to play. Did you get any errors in the output?

What is the priority of the animation? If it’s set to idle or something lower, then the default animations may be overriding it.

Didn’t work and it printed the last print(). (No errors in output btw)

local RemoteEvent = game.ReplicatedStorage.BestLawyer

RemoteEvent.OnServerEvent:Connect(function(player, Key)
	print("Pressed key")
	if Key == "Z" then
		print("Animation Playing")
		local Animation = game.ReplicatedStorage:WaitForChild("DeskSlam")
		local AnimTrack = player.Character:WaitForChild("Humanoid"):WaitForChild("Animator"):LoadAnimation(Animation)
		AnimTrack:Play()
		print("I dont know what to put in here")
	end
end)

It’s set to Action. Btw these two are the only scripts in my game right now so I have no idea why this isn’t working.

Maybe you should take the animation out of replicatedstorage and move it into the script?

local RemoteEvent = game.ReplicatedStorage.BestLawyer

RemoteEvent.OnServerEvent:Connect(function(player)
	if player then
		local character = player.Character or player.CharacterAdded:Wait()
		local humanoid = character:WaitForChild("Humanoid")
		
		print("Pressed key")
		print("Animation Playing")
		local AnimTrack = humanoid.Animator:LoadAnimation(script:WaitForChild("animation"))
		AnimTrack:Play()
		
	end
end)

I dont see any need for adding a “key” variable.

local UserInputService = game:GetService("UserInputService")
local player = game.Players.LocalPlayer

local debounce = false
local RemoteEvent = game.ReplicatedStorage.BestLawyer

UserInputService.InputBegan:Connect(function(input)
	if debounce == false then
		if input.KeyCode == Enum.KeyCode.Z then
			debounce = true
			RemoteEvent:FireServer()
		end
	end
end)

Omg I’m so stupid. I forgot my animations are R6 and my character is R15. Sorry for wasting your time.

3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.