Animation not playing

Hello!
This is my first time posting a topic on the developer forum so I hope some people can help me with my problem.

What do I want to achieve?
I want to make this animation play by scripting but it isn’t working.

What is the issue?
So basically I want to make a electric chair for my V2 up coming prison game called Eastside. There’s a lever that you pull and once it goes down the invisible seat goes to a certain position to preform the animation, kills the person, then the animation seat goes back to the usual position. The problem is that the animation that is suppose to play wont play for the other person

What solutions have you tried so far?
My solutions I’ve tried so far are putting the animation script in a different script so when the lever pulls down then it would enable the script so the animation could play.

By the way both of them are in a normal script
The script that enables it

local proximityprompt = script.Parent.Parent.Trigger:WaitForChild("ProximityPrompt")
local Players = game:GetService("Players") 
local tweenService = game:GetService("TweenService")
local debounce = true
local Lever = script.Parent.Parent.Trigger
local DC = script.Parent.Parent["Eletric Chair Seat"]

local Down = tweenService:Create(Lever,TweenInfo.new(1,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{Position = Vector3.new(-488.287, 50.74, 60.115)})

local Up = tweenService:Create(Lever,TweenInfo.new(1,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),{Position = Vector3.new(-488.287, 51.263, 60.115)})

proximityprompt.Triggered:Connect(function(Player)
	if Player.Team == game.Teams["High Command"] then
		if debounce == true then
			debounce = false
			Down:Play()
			wait(1)
			DC.Position = Vector3.new(-476.187, 50.967, 63.111)
			script.Parent.Animation.Disabled = false
			script.Disabled = true
			wait(5)
			script.Disabled = true
			script.Parent.Animation.Disabled = true
			script.Parent.Kill.Disabled = false
			wait(1)
			script.Parent.Kill.Disabled = true
			DC.Position = Vector3.new(-476.074, 49.367, 63.42)
			Up:Play()
				end
		end
end)

The animation script

seat = script.Parent.Parent["Eletric Chair Seat"]
function added(child)
	if (child.className == "Weld") then
		local human = child.part1.Parent:FindFirstChild("Humanoid")
		if human ~= nil then
		anim = human:LoadAnimation(seat.sitanim)
			anim:Play()
		end
	end
end
function removed(child2)
	if anim ~= nil then
		anim:Stop()
		anim:Remove()
	end
end

seat.ChildAdded:connect(added)
seat.ChildRemoved:connect(removed)

Please let me know if I did anything wrong.
Thank you.

Please don’t use global variables, local variables are better practice. Also realize that Humanoid:LoadAnimation() has been deprecated for a long time (still surprised people actively use it), use Animator:LoadAnimation()

1 Like