Basically, in my game I use a lot of NPC’s and they will each have animations, I recently found that using GetMarkerReachedSignal is a really good way to have specific moments in an animation to play a sound or visual effect, the problem is however all my NPC’s handling is done on the server and GetMarkerReachedSignal can only be used on the client, so I’m not too sure how I should communicate between the server-sided script and client-sided script, obviously I will use RemoteEvents but how can I go about detecting if the animation is playing in the first place? And would I have to create a RemoteEvent for each specific ability animation in my game?
This is what I have in my local script, none of this functions properly though because I’m not sure how to detect when a specific animation is playing in my game, that’s my main issue.
-- // SERVICES // --
local RunService = game:GetService("RunService")
-- // VARIABLES // --
local NPC repeat NPC = game.Workspace:FindFirstChild("Subzero") task.wait() until NPC
local WalkAnimation = NPC.Humanoid:LoadAnimation(NPC.Animations.Walk)
local IdleAnimation = NPC.Humanoid:LoadAnimation(NPC.Animations.Idle)
local Ability1Animation = NPC.Humanoid:LoadAnimation(NPC.Animations.Melee)
local Ability2Animation = NPC.Humanoid:LoadAnimation(NPC.Animations.IcicleRaise)
local Humanoid = NPC:FindFirstChild("Humanoid")
RunService.RenderStepped:Connect(function()
-- testing purposes, nothing was printed though
if Ability2Animation.IsPlaying then
print("found")
end
if WalkAnimation.IsPlaying then
print("foundWalk")
end
end)
after a little bit i have sorta a solution but i still need some help with it.
i have this line of code in my npc’s server script
game.ReplicatedStorage.Events.AnimationEvent:FireAllClients(Ability2Animation)
and then i have this line in my client script but it prints it as nil and i’m not sure why
game.ReplicatedStorage.Events.AnimationEvent.OnClientEvent:Connect(function(Animation)
print(Animation)
end)