I have a windscreenwiper animation that plays as intended on the client but doesn’t play on the server even though it’s inside a server script. The animation also does not stop when I do animation:Destroy() which is primarily impossible.
Server script:
WipeEvent.OnServerEvent:Connect(function(player, cmd)
local WiperAnimationFront = Instance.new("Animation")
WiperAnimationFront.AnimationId = "rbxassetid://13041346049"
WiperAnimationFront.Parent = script.Parent.WipersFront
local WiperAnimationBack = Instance.new("Animation")
WiperAnimationBack.AnimationId = "rbxassetid://13041346049"
WiperAnimationBack.Parent = script.Parent.WipersBack
local WiperAnimB = AnimatorCoachB:LoadAnimation(WiperAnimationFront)
local WiperAnimF = AnimatorCoachF:LoadAnimation(WiperAnimationBack)
if CoachB.IsFrontCoach.Value == true and cmd == "Enable" then
WiperAnimB:Play()
elseif CoachB.IsFrontCoach.Value == true and cmd == "Disable" then
WiperAnimationFront:Destroy()
elseif CoachF.IsFrontCoach.Value == true and cmd == "Enable" then
WiperAnimF:Play()
elseif CoachF.IsFrontCoach.Value == true and cmd == "Disable" then
WiperAnimationBack:Destroy()
end
end)
The client script is pointless to show because it only sends a cmd variable
Destroying the Animation object does not mean it will stop. You must destroy the AnimationTrack to make it stop.
So do
WiperAnimB:Destroy()
instead of
WiperAnimationFront:Destroy()
I would also like to note that it is not good practice to continuously load animation tracks without destroying them. Once you reach the limit of 256 tracks, your script will stop working and no animations will play.
I am unsure as to why the animation would not be playing on the server. Is the game under your profile and is the animation also under your profile? If the game is under another profile or a group and the animation is uploaded under your profile, then only you will see it.
Oh right I thought about trying that but I didn’t think that destroying an animation track would work, Thanks!
I did what you said and the animation still does not stop oddly. whenever the “Disable” cmd is received it just does that line of code that checks if it “Disabled” (I know this because I put a print there). The game is under my profile. Instead of firing a remote event from the client would it be possible to get the playergui through the server and check when the player presses a button. I can get the player in this script with VehicleSeat.Occupant
When are these values changed? If they are never changed, then it may not be functioning as intended.
I would also like to note that each command will only be able to turn off one wiper animation at a time. I unsure whether this is intentional or not.