Animations not showing globally, despite activated by server script

I am currently trying to make doors open using animations, however, there is an inconsistancy issue where it doesnt show for most players

My perspective

Another players perspective

The doors are controlled by a server script inside the train. The code for the doors is as follows

local values = script.Parent.Parent:WaitForChild("Values")

values.DoorsOpen.Changed:Connect(function()
	if values.DoorsOpen.Value == true then
				local animationTrack = script.Parent.Rigged.AnimationController:LoadAnimation(script.Parent.Rigged["Doors"..values.DoorSide.Value])
				animationTrack:Play()
				animationTrack:GetMarkerReachedSignal("Open"):Connect(function()
					animationTrack:AdjustSpeed(0)
					while true do
						wait(1)
						if values.DoorsOpen.Value == false then
							animationTrack:AdjustSpeed(1)
					break
				end
				end
				end)

	end
end)


There are no errors or warnings for this, but seems to only show for the driver of the vehicle. How do I fix this issue.

Try it in a LocalScript maybe? Works for me with character animations :man_shrugging:

Its using AnimationControllers. I tried previously, and the local script wouldnt recognise when the values changed at all

1 Like

Is the first picture taken in studio play mode?

both in game taken at about the same time by different people

This part of your code has me slightly confused. What you attempting to do is constantly adjust the AnimationTracks speed to 1 while the doors aren’t open? This shouldn’t need a loop unless something else is changing the speed constantly as well; if that is the case, then one script is getting priority over another most likely. My suggestion would be to do all of this from a localscript in the client.

I’ll try converting it local (again) and change that bit, but it doesnt explain why it only played the animation for the vehicle driver and no one else on the server

Ah! Is the vehicle within the character of the player? If so, then it is local to the player, and the door scripts are being ran by that player’s client

No, its within a folder in the server. The driver has network ownership of the vehicle and is sat within a seat inside it, but is not parented to the player. The animations are played via an AnimationControllr

I have converted the animations to play locally through the player, however, it no longer recognises the vehicles existance and doesnt output any errors or prints

local vehicle = workspace.Trains[script.Value.Value.."Train"]
local train = vehicle:GetDescendants()
local values = vehicle.Values

workspace.Trains.ChildRemoved:Connect(function(instance)
	  if instance.Name == script.Value.Value then
		print(script.Value.Value.." train removed")
		script:Destroy()
	end
end)


values.DoorsOpen.Changed:Connect(function()
	print("changed")
	if values.DoorsOpen.Value == true then
		for index, descendant in pairs(train) do
			if descendant:IsA("AnimationController") then
				local animationTrack = descendant:LoadAnimation(descendant.Parent["Door"..values.DoorSide.Value])
				animationTrack:Play()
				animationTrack:GetMarkerReachedSignal("Open"):Connect(function()
					animationTrack:AdjustSpeed(0)
					while true do
						wait(1)
						if values.DoorsOpen.Value == false then
							animationTrack:AdjustSpeed(1)
							break
						end
					end
				end)
			end
		end
	end
end)

Removing the vehicle from its folder does not produce anything, nor the values changing, while the server could previously detect both

Did you find a solution, I’m having the same issue

So, the problem might be that you are using an Animation Id that the game Owner does not own. In game, it will only run for the devs or the animation owner. Make sure the animation asset is uploaded in the game’s owner (in the group if it is a group, or the player account if it is a player)

@ Sindious

Yeah I’ve already been told that by someone. I got around this problem by not using a remote event, Im suspecting this is an engine bug but Im not entirely sure.

Remote event for what? It probably has nothing to do with the animation

I found the issue: the animations weren’t being loaded inside the .OnServerEvent function. Dont know why this made the animation server sided but it’s alr now.

Can you show the code on where it wasnt working? Im almost sure that wasnt the problem

local WiperAnimB = AnimatorCoachB:LoadAnimation(WiperAnimationFront)
local WiperAnimF = AnimatorCoachF:LoadAnimation(WiperAnimationBack)

local IsWiping = false



WipeEvent.OnServerEvent:Connect(function(player)
	if IsWiping == false then
		WiperAnimB:Play()
		IsWiping = true
	elseif IsWiping == true then
		WiperAnimB:Stop()
		IsWiping = false
	end
end)

After:


WipeEvent.OnServerEvent:Connect(function(player)
	if IsWiping == false then
		local WiperAnimB = AnimatorCoachB:LoadAnimation(WiperAnimationFront)
		WiperAnimB:Play()
		IsWiping = true
	elseif IsWiping == true then
		local WiperAnimB = AnimatorCoachB:LoadAnimation(WiperAnimationFront)
		WiperAnimB:Stop()
		IsWiping = false
	end
end)

Well, your animations are still server sided sinse they are loaded in an OnServerEvent. I think it might be kindda dangerous loading a new anim every time, we are not sure if roblox properly clean the unused tracks… To keep sure of that i would add a

track.Completed:Connect(function() track:Destroy() end)

Nothing seems wrong with the first script also, I would guess if that didnt work then there might be something wrong with the AnimatorCoach variables, make sure you used :WaitForChild() on getting them, sometimes the Animator instance inside the Humanoid or AnimationController does no load and you have to create one.

1 Like