Animation not playing

ive made a jumpscare animation but the animation for it wont play could somebody please help

local attack = script.Animation
local attackAnim = script.Parent.Animator:LoadAnimation(attack)

game.ReplicatedStorage.Remotes:WaitForChild("playerDeath").OnServerEvent:Connect(function()
	print("detected")
	attackAnim:Play()

end)


1 Like

Why script.parent.animator. is the script inside the humanoid?

its inside of an animation controller

So, you need to fire RemoteEvent from client to server?

In that case, you need to fire RemoteEvent and setting which exact client will fire it but you made an mistake while firing it.

Make sure that you have a player to fire Remote Event from a client!

local attack = script.Animation
local attackAnim = script.Parent.Animator:LoadAnimation(attack)
local player = game:GetService("Players"):GetPlayers()[1] -- there is suppose to be a player but i have just used GetPlayers and returned one player that contains in GetPlayers table. anyway feel free to change the variable!

game.ReplicatedStorage.Remotes:WaitForChild("playerDeath").OnServerEvent:Connect(function(player)
	print("detected")
	attackAnim:Play()
end)

If you want to know additional information about Remote Events, make sure to read this documentation: Remote Events and Functions | Documentation - Roblox Creator Hub

it seems that the issue is that nothing is receiving the remote event, however, the script firing it looks fine
server script:

 local player = game.Players:GetPlayerFromCharacter(target)
	
game.ReplicatedStorage.Remotes:WaitForChild("playerDeath"):FireClient(player)
	print("d1")

then the local script (which should receive it and fire another event to the server) doesnt receive it for some reason
local script:
game.ReplicatedStorage.Remotes:WaitForChild(“playerDeath”).OnServerEvent:Connect(function(player)
print(“d2”)
game.ReplicatedStorage.Remotes:WaitForChild(“j1”):FireServer(player)
end)

You made a mistake here :

game.ReplicatedStorage.Remotes:WaitForChild(“playerDeath”).OnServerEvent:Connect(function(player)

it’s supposed to be OnClientEvent since it’s a local script

game.ReplicatedStorage.Remotes:WaitForChild(“playerDeath”).OnClientEvent:Connect(function(player)

it still doesnt detect the remote event firing

Is the animation controller inside a model? Also, try doing AnimationController:LoadAnimation(yourAnim) and delete the Animator inside the controller. You can’t fire an event on the server and try to get the data on a serverscript. Events can only communicate between server - client. Not server - server!

i put a middle man local script in to receive the event and fire another

oops sorry. my eyes arent working

There is no mistake with the code from the looks of it. I was helping another guy and he had the same issue with his remote event. Event does not fire on server - Help and Feedback / Scripting Support - Developer Forum | Roblox I am pretty sure its just Roblox having issues.

It worked just fine for me. Might be the way you are collecting the character’s death! PS I CHANGED THE LOCATION OF THE REMOTES SO CHANGE THEM TO YOURS

Server script :

Players.PlayerAdded:Connect(function(player)

	player.CharacterAdded:Connect(function(character) 
		local Humanoid = character:FindFirstChildOfClass("Humanoid")
		Humanoid.Died:Connect(function()

			game.ReplicatedStorage:WaitForChild("playerDeath"):FireClient(player)
			print("d1")
			end)
		end)
end)

game.ReplicatedStorage:WaitForChild("j1").OnServerEvent:Connect(function(player)
print("Success"..player.Name)
end)

Local script :

game.ReplicatedStorage:WaitForChild("playerDeath").OnClientEvent:Connect(function(player)
	print("d2")
	game.ReplicatedStorage:WaitForChild("j1"):FireServer(player)
end)

Must be, since the code is pretty much identical

where did you put the local script at

in the animation controller of the model

i think i might just use the characters death to trigger the animation instead of remote events since that seems to be working

I’m pretty sure… Local Scripts wont work if they arent a descendant of the local player

try moving it to StarterCharacterScripts and check if it works

I don’t understand what happened internally I do know that the issue that happened internally probably caused this.

Seems like an easier approach so probably the best, yes