And skills have differents animations, so i will need send the animations for the client using remote events (since is better active the animations on client), however some skills I did have several animations, so I activate the animations in order using Track.Stopped and some skills no, so instead of just sending the animations, I wanted to send a function that will control the animations.
local function playTrack(Character,Id,Id2)
print("FUNCTIO NWORKING LMAO")
local Animation = Instance.new("Animation")
Animation.AnimationId = Id
local Track = Character:WaitForChild("Humanoid"):LoadAnimation(Animation)
Animation.AnimationId = Id2
local Track2 = Character:WaitForChild("Humanoid"):LoadAnimation(Animation)
Track.Stopped:Connect(function()
Track2:Play()
end)
Track:Play()
end
SendAnimation:FireClient(player,playTrack,{Character,"rbxassetid://4717948056","rbxassetid://4718138141"})
local SendAnimation = game:GetService("ReplicatedStorage").Remotes.SendAnimation
local function playT(trackF,Args)
trackF(unpack(Args))
end
SendAnimation.OnClientEvent:Connect(playT)
References to functions cannot be sent over because they do not serialize. They could be serialized but the effort required to serialize them yields no usefulness. But I must ask; why do you want to send a function???
It’s not working because you cannot send functions through Remotes. I’d recommend you have the function in the client script instead of the server, as it’s not even used in the server-script.
-- client
local SendAnimation = game:GetService("ReplicatedStorage").Remotes.SendAnimation
local function playTrack(Character,Id,Id2)
print("FUNCTIO NWORKING LMAO")
local Animation = Instance.new("Animation")
Animation.AnimationId = Id
local Track = Character:WaitForChild("Humanoid"):LoadAnimation(Animation)
Animation.AnimationId = Id2
local Track2 = Character:WaitForChild("Humanoid"):LoadAnimation(Animation)
Track.Stopped:Connect(function()
Track2:Play()
end)
Track:Play()
end
SendAnimation.OnClientEvent(function(Args)
playTrack(unpack(Args))
end)
Edit: If you really, really need to send functions through RemoteEvents/RemoteFunctions, you could write the code as a string, and have the client execute it through either loadstring or EpicLua. I’d highly suggest against this though.
because my skills have several animations, I put events in them or use Stopped to activate the next animation, could I leave this function in localscript? NO, because not everyone will have this skills, since it is an RPG type game, so I’m trying to do something that will work with any skills, something generic
If you want to make sure the client isn’t playing the animations without having the appropriate criteria, by all means you can send a RemoteFunction/Event to the server confirming if the player does or does not have the ability (via Data recorded by DataStore/ Objects) to use this exclusive skill.
Even if they ran the animations and skills locally, the server would not acknowledge it (unless you have a bad client-server implementation of FE)
A work around however, would be to place the function in a Module Script on the Client and require it to run the function.
You can also enable Loadstring and send scripts from the server to the Client but this option is risky because it allows Clients to run dynamic code where the strings can run as code on the Server, sent through Remote Functions.
it will not work, first because the skill is on the server, and I will only continue the skill when the animation arrives at a certain frame, if I am activating it on the client there is no way for me to check on the server