local CollectionService = game:GetService("CollectionService")
local TweenService = game:GetService("TweenService")
local Clicked = {}
local TaggedDoors = CollectionService:GetTagged("Doors")
for _, TaggedDoor in ipairs(TaggedDoors) do
local Backward = TaggedDoor.PrimaryPart.CFrame
local Forward = Backward * CFrame.new(0, 6.3, 0)
local CFrameValue = Instance.new("CFrameValue")
CFrameValue.Value = Backward
CFrameValue.Changed:Connect(function(New)
TaggedDoor.Door:SetPrimaryPartCFrame(New)
end)
TaggedDoor.Door.Interactive.Interactive.ClickDetector.MouseClick:Connect(function(Player)
Clicked[TaggedDoor] = not Clicked[TaggedDoor]
TweenService:Create(CFrameValue, TweenInfo.new(0.5), {Value = Clicked[TaggedDoor] and Backward or Forward}):Play()
end)
end
This should work if you have tagged your doors properly, didn’t test this though and obviously there are more efficient ways to achieve your desired result. Also i’d recommend if you’re trying to tween a model to not use this method as SetPrimaryPartCFrame is known for it’s weird behaviour. If you’re looking for a better method i’d recommend checking out colbert’s thread Introduction to Tweening Models