Help with playing a different animation whenever a value goes to true?

I’m making a FNAF fan game, so whenever this BoolValue named “OfficeDoorShined” goes to true, a different animation is supposed to play.

It does not play at all, the animation IDs are correct, yet the animation doesn’t play when the BoolValue is true and I don’t get any errors. (I have confirmed the BoolValue goes to true)

I’ve looked around on here, and the docs (And tried doing it myself), but unfortunately no success. :frowning_face:

This is the code! Note: The animation on the character’s humanoid is called “EnemyCharlotte” and “animationLeave” was supposed to be the animation I’m wanting to play after the BoolValue is true. AtDoor is the animation that should stop whenever the BoolValue is true.

local animation = script:WaitForChild('AtDoor')
local animationLeave = script:WaitForChild('Leave')
local humanoid = script.Parent:WaitForChild('EnemyCharlotte')

local dance = humanoid:LoadAnimation(animation)
local danceLeave = humanoid:LoadAnimation(animationLeave)

dance:Play()

if workspace.OfficeDoorShined.Value == true then
	local leave = workspace.OfficeDoorShined.Value
	if leave and leave:IsA("Value") and leave.Enabled == true then
		humanoid:StopAllAnimations()
		dance:Stop()
		danceLeave:Play()
	end
end

Thanks! (Sorry if my grammar or spelling is bad, this was a bit rushed)

You’re running a simple if statement that only plays once.
Connect an event, like so:

workspace.OfficeDoorShined:GetPropertyChangedSignal("Value"):Connect(function()
    if workspace.OfficeDoorShined.Value == true then
    --code
end)