I created my own animation and you can trigger the animation by pressing "q"
This is a LOCAL SCRIPT:
01 | Player = game.Players.LocalPlayer |
02 | Mouse = Player:GetMouse() |
03 | local fly = Player.Character:WaitForChild( "Duck" ):WaitForChild( "AnimationController" ).Fly |
04 | local flying = Player.Character:WaitForChild( "Duck" ):WaitForChild( "AnimationController" ):LoadAnimation(fly) |
05 |
06 | Mouse.KeyDown:connect( function (key) |
07 | if key = = "q" and script.Fly.Value = = false then |
08 | script.Fly.Value = true |
09 | flying:Play() |
10 | end |
11 | end |
12 | if key = = "q" and script.Fly.Value = = true then |
13 | script.Fly.Value = false |
14 | flying:Stop() |
15 | end |
16 | end ) |
The animation works fine in studio, and it DOES PLAY online, but only for the player triggering it, and other players can't see it.
When I tried to put it in a regular server script, that made the animation not play at ALL online.
What's the problem? ((Please be detailed in your answer, vague answers do not help me, thank you!))
The reason it is only appearing for you is that you have Filtering Enabled on, which is recommended, but it also filters local scripts to only apply locally. I do not know if this is the problem, try changing it to a regular script.
Instead of using values, use a variable to determine if the player is flying or not.
Animations play for everyone with FilteringEnabled on without RemoteEvents.
01 | local Player = game.Players.LocalPlayer |
02 | local Character = Player.Character |
03 | local Humanoid = Character.Humanoid |
04 |
05 | local Mouse = Player:GetMouse() |
06 |
07 | local Animation = Instance.new( 'Animation' ) |
08 | Animation.AnimationId = "" -- paste your animation id here |
09 | local FlyTrack = Humanoid:LoadAnimation(Animation) |
10 |
11 | local Flying = false -- determines if the player is flying/not |
12 |
13 | Mouse.KeyDown:connect( function (key) |
14 | if key = = "q" and not Flying then |
15 | Flying = true |
I have had that same problem before and most of the time it happens when ever the animation editor you use has a default looped or priority option that for some reason doesn't allow scripts to change those said properties of loaded animation track(s); you might want to try setting those properties in your editor and see if that fixes it (looped and priority). Also you want to make sure that if your animation is being looped that the length is around a good two seconds. From my experience, simply changing the properties in the animation editor itself and or changing the length to be longer usually resolves this issue. One more thing, make sure your only referencing the animations once in the scripts or more bugs/glitches could possibly occur. Hope this helped, bye!
Thank you for your input, I tried this too, and I'm still having the same problem: I can see my character's animation, but other players can't. I've been scratching my head on this for days and made several different scripts to tackle it, but none of them seem to make any difference.
01 | local Player = game.Players.LocalPlayer |
02 | local Character = Player.Character |
03 | local Humanoid = Instance.new( 'Humanoid' ) |
04 | Humanoid.Parent = Character:WaitForChild( "Duck" ) |
05 | local Mouse = Player:GetMouse() |
06 |
07 | local Fly = Instance.new( 'Animation' ) |
08 | Fly.AnimationId = "rbxassetid://1760611761" |
09 | local FlyTrack = Humanoid:LoadAnimation(Fly) |
10 |
11 | local Flying = false |
12 |
13 | Mouse.KeyDown:connect( function (key) |
14 | if key = = "q" and not Flying then |
15 | Flying = true |
I used the script above in a SERVER script, which made the animation not play at all, and then on a LOCAL script, which made the animation play for me, but, others can't see it.
I changed the AnimationController I WAS using previously to play the animation to a Humanoid to see if that was the problem.
I also changed the priority of the animation to Action and made the animation longer (was 0.5 seconds, now its 2 seconds) and this didn't seem to change a thing.
You say that I don't need remote events for the animation to play on a character, so what else can I do?