I made an animation for a door opening and when i write a script for it, it doesnt work. It definitely detects when i press a key but it doesnt open the door. My script:
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Button = game.Workspace.DoorFolder.Door.Prompt.TextButton
local key = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")
local info = TweenInfo.new(3, Enum.EasingStyle.Sine, Enum.EasingDirection.In, 0, false, 0)
local EndGoal = {Orientation = Vector3.new(0, -158.659, 0); }
local Door = game.Workspace.DoorFolder.Door
local TargetDoor = game.Workspace.DoorFolder.Door
local DoorAnimation = Instance.new("Animation")
DoorAnimation.AnimationId = "http://www.roblox.com/asset/?id=11962577878"
DoorAnimation.Parent = game.Workspace.DoorFolder.Door
key.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.E then
local animationController = Instance.new("AnimationController")
animationController.Parent = DoorAnimation.Parent
local animator = Instance.new("Animator")
animator.Parent = animationController
local DoorAnimationTrack = animator:LoadAnimation(DoorAnimation)
DoorAnimationTrack:Play()
print("test")
end
end)

4 comments
Are there any errors in output/does it print "test"?
Try creating the Animation, AnimationController, and Animator in the Door manually and not by script.
it seem you have a duplicate code at the top as Door and target door vales are the same
i will test all of these thank you!