First off I’m pretty familiar with custom rigging/morphs, animating and scripting stuff involving the humanoid, but today I ran into something I’ve never had to do. I’m working on an opening cut scene for one of my games and I have a rig that’s suppose to play an animation and basically turn around and face the camera when it pans up to them. The issue is I wanna have the animation play at the right time for every player that joins so the logical thing i thought to do was try and code it from the client side. I tried a couple things such as loading the animation into the humanoid through a local script then playing it or using remote events/functions to play it and neither worked only on the client side. Loading it through the server side worked fine tho but I don’t wanna have one person join and see part of the animation then another player join and it restarts the animation. If anyone has anything that can point me in the right direction of where to go with this that would be great. For now I’m planning to look into the Animation Controller object next and see if there’s anything that object can do that the humanoid can’t
Hi, I recently answered a similar question. Instead of using
:FireAllClients() from the server, fire the remote to just one client using
:FireClient(player) (the player that joined).
This is actually how I was already trying to do it when i mentioned remote events. On my local script I did FireClient(Player) having Player be my variable for LocalPlayer, sent to a remote event then a server script/NPC, but the thing was remote events fire server scripts and when the animation plays through 1 server script any other client can see the animation playing if they’re on the start screen/by the NPC in game. What I’m trying to do is make it only play on the client side for the player that fired the remote but I honestly think using a remote wont work due to what i mentioned above. If I’m wrong please let me know what I can do to get around this
FireAllClients() can only be called from the server. When a player joins you will use
FireClient(playerThatJoined) in your server script.
In the local script you will use the
.OnClientEvent event to detect when the server fired the remote at the client, and inside the function connected to
.OnClientEvent, play the animation track.
Ahh yes my bad I was thinking fireserver for some reason and wrote that above, that’s what happened with fire server anyways. I also did try fireClient too but it didn’t work. When i load the animation into an NPC’s humanoid through my client and then play it the animation wouldn’t play. That is why I’m thinking about looking into using an Animation Controller because the humanoid object might just not work for that sort of thing. If you’re not loading the animation into the humanoid then playing it, how are you playing your animations on the client side?
I just tried using Fire Client again from a server to local script, same result though, it didn’t play the animation on the local script D:
What are the errors? You really should read that thread I sent you. It goes over many many issues, some of them you may be experiencing
It also explains what’s happening for your understanding
There are no errors in my scripts, that’s why I’m asking here
Can you share the scripts so I can check out what’s going on?
There’s more to my scripts but this is the animation parts of it, I have two ways of loading the animations into the NPC on the client side and neither worked on the local script but work fine on server scripts. The issue could also be that I need to move my local script into my player because right now it’s in the NPC.
local Players = game:GetService(“Players”)
local plr = script.Parent
local animation = Instance.new(“Animation”)
animation.AnimationId = “http://www.roblox.com/Asset?ID=4817614204”
local animTrack = plr.Humanoid:LoadAnimation(animation)
if not animTrack.IsPlaying then
Aye i just moved the local script i was using to animate the NPC into my player and it worked!
Where was the Local Script before? Btw, you forgot to reply to me so I didn’t see it earlier
My bad still a little new to posting. Anyways I started the animation script on a server script inside of my NPC, it just looped an idle animation so a server script worked fine. Later I swapped up the animation and tried to run it from the client’s side, the first thing i did was replace the server script inside of the NPC with a local script, which created the issue. Thinking about it now I can’t believe I slipped up like that, it’s so obvious it should’ve stayed somewhere in the player since that is the client