Door Script not working

Trying to make a door open “animation” when the boat anchors. For some reason, it does nothing when the boat anchors. Help will be appreciated. Thanks! :smiley:

Code:

local Boats = workspace:WaitForChild(“Boats”)
local AnchorPoint = script.Parent
local TS = game:GetService(“TweenService”)
local tweeninfo = TweenInfo.new(1)

AnchorPoint.Touched:Connect(function(hit)
if hit.Parent.Parent.Parent.Parent.Name ~= “Boats” then return end
for i,v in pairs(hit.Parent.Parent.Parent:GetDescendants()) do
if v:IsA(“BasePart”) then
v.Anchored = true
local door = hit.Parent.Door
local hinge = hit.Parent.Hinge
local doorHeight = door.Size.Y
local verticalOffset = doorHeight / 2 + 1.8
local openState = {}
openState.Position = hinge.Position + Vector3.new(0, verticalOffset, 0)
openState.Rotation = door.Rotation + Vector3.new(-90, 0, 0)
local OpenAnim = TS:Create(door, tweeninfo, openState)
OpenAnim:Play()
end
end
end)

2 Likes