Train door animation not playing

Im making a train door Open/Close animation and I have started scripting the train door Open function however It doesn’t seem to be working and it has no errors.

task.wait(5) -- these animations will be created when the train spawns
local DoorOpenAnimation = Instance.new("Animation", DoorFolder.Door)
DoorOpenAnimation.AnimationId = "rbxassetid://14387852813" 

local DoorCloseAnimation = Instance.new("Animation", DoorFolder.Door)
DoorCloseAnimation.AnimationId = "rbxassetid://14387863027" 

local OpenAnim = Animator:LoadAnimation(DoorOpenAnimation)
local CloseAnim = Animator:LoadAnimation(DoorCloseAnimation)

local function OpenDoor()
	for _, interlockLight in InterlockLights do
		interlockLight.Material = "Neon"
	end

	local UnlockSound = Instance.new("Sound", ProximityPrompt.Parent)
	UnlockSound.Name = "DoorUnlock"
	UnlockSound.RollOffMaxDistance = 100
	UnlockSound.Volume = 1
	local newEqualizer = Instance.new("EqualizerSoundEffect", UnlockSound)
	newEqualizer.HighGain = 10
	newEqualizer.LowGain = -80
	newEqualizer.MidGain = -19.7
	newEqualizer.Priority = 0

	UnlockSound:Play()

	DoorFolder.Door.InteriorDoorLight.Material = "Neon"
	OpenAnim:Play()

	OpenAnim.Ended:Connect(function()
		for _, v in pairs(DoorFolder.PosOpen:GetDescendants()) do
			if v:IsA("BasePart") or v:IsA("MeshPart") then
				v.Transparency = 0
			elseif v:IsA("TextLabel") then
				v.TextTransparency = 0
			end
		end
	end)
	
	UnlockSound.Ended:Connect(function()
		UnlockSound:Destroy()
		print("sound ended")
	end)
end

ProximityPrompt.Triggered:Connect(function(player)
	OpenDoor()
end)

The Animation.Ended event gets fired so I dont really understand the issue here :confused:
And the “UnlockSound” does not play

Also can someone tell me when the best time is to use the :LoadAnimation() I heard it could be unoptimised if you do it inside a function that gets called multiple times.

edit: ive been trying and debugging and couldnt resolve this, also every time i press on my rig in the animation editor roblox studio crashes

2 Likes

I think the issue here is Material. It should be Enum.Material.Neon (I dont remember what after Enum but it have to be enum to set part’s material

Both work but I dont think thats the issue as I use .Material = “Neon” in another part of my game and its ok

oh ok. The sound i think it is because you didn’t set its sound id so it doesn’t play any sound. As for anything else i can’t think of any solutions i can’t see what’s wrong here

1 Like

Oh yeah I forgot that but my main issue is the animation not playing :confused:

Can i see your door with all the childs?
Also i see people saying we should use .Parent instead when using Instance.new it make some issues but i don’t think it is the case here just so you know.
Oh and what is InterlockLights here exactly

Interlock lights is just a light on the door that is not part of the door rig, they are there to display whether or not the door is open.
image

I meant how did you call it like local InterlockLights = ?
Also i tested the script the animation did play so if you can give me the infomation about this InterlockLights i might think of something. If that doesn’t help anything then i can’t help you anymore

Okay thanks for the information I probably did something wrong with the rigging and ill look more into it

1 Like

Animator is not defined?

remove30charrule

The animator is defined earlier in the code.

1 Like