Hi, I am making a game and I have some gun animations that I need to show to other clients. All animations seem to work fine, however there is one that does not appear to co-operate. It only shows the animation for the client who’s initializing the animation.
Before we proceed: yes, all the animations including the faulty one are owned by me, the faulty one has been made by me which could be the problem however I am unsure.
The issue, as stated above is that all gun animations work except for one. Which is confusing me. This script was a commission for me and I already spoke to the programmer about it, he said he had no clue so I figured I might have some luck here.
I performed the tests in a local studio server. Below is Player2, he is executing the desired animation after having pressed Q.
At the same time, I had Player1 also run the same animation as described above. Note that they are BOTH performing the animation at the same time in these screenshots and I did not deactivate them at any given time during these screenshots.
In comparison I have the sprinting animation active:
This worked fine for both clients.
Solution wise, I tried following the format of the scripter I commissioned, he used UIS to connect keybinds to the animation and in most events he fired to the server which I also tried to see if that fireserver made the animation replicate by chance (it did not).
Code block function: managing and replicating all animations to the other players when the matching key is pressed and the tool is equipped.
Source: WeaponScript (a localscript located in the StarterGUI as child of the main weapon UI element)
game:GetService('UserInputService').InputBegan:connect(function(Key,GPE)
if not GPE and Equipped then
local KChar=utf8.char(Key.KeyCode.Value)
if KChar=='r' and Equipped.Ammo.Value<Equipped.Ammo.Max.Value and not Reloading and not Anims['Sprint'].IsPlaying and not Mouse1Down and Equipped.Clips.Value>0 then
Reloading=true
Equipped.Handle.Reload:Play()
Anims['Reload']:Play()
Event:FireServer('Reload',Equipped)
wait(Anims['Reload'].Length)
if Equipped then
UpdateUI(Equipped)
end
Reloading=false
elseif KChar=='f'and not Reloading then
if Anims['Sprint'].IsPlaying then
Anims['Sprint']:Stop()
Event:FireServer('Speed',16)
else
Anims['Sprint']:Play()
Event:FireServer('Speed',22)
end
elseif KChar=='x'and not Reloading and not Mouse1Down and not Anims['Sprint'].IsPlaying and Equipped.Handle.Melee.Value==false then
Anims['Melee']:Play()
Equipped.Handle.Swing:Play()
Equipped.Handle.Melee.Value=true
wait(Anims['Melee'].Length)
Equipped.Handle.Melee.Value=false
elseif KChar=="q" and not Reloading and not Mouse1Down and not Anims['Sprint'].IsPlaying then
if Anims['Guard'].IsPlaying then
Anims['Guard']:Stop()
Event:FireServer('Speed',16)
else
Anims['Guard']:Play()
Event:FireServer('Speed',16)
end
end
end
end)
Sidenote: the FireServer events after the animation is stopped or ran were meant to test if the issue was the lack of such an event, however it did not matter if they were in there or not.