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.
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
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)
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.
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.
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
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.