I’m trying to make a door tween script and everything is working expect for the door close tween is tweening weird
Video:
Code:
local Collection = game:GetService("CollectionService")
local Doors = Collection:GetTagged("Doors")
local Tween = game:GetService("TweenService")
local doortweeninfo = TweenInfo.new(0.3, Enum.EasingStyle.Linear, Enum.EasingDirection.In,0,false,0)
local function setupdoors(DoorModel)
local ClosedValue = DoorModel:WaitForChild("Closed")
local OpenedValue = DoorModel:WaitForChild("Opened")
local Prompt = Instance.new("ProximityPrompt")
Prompt.Name = "Prompt"
Prompt.Parent = DoorModel
Prompt.ObjectText = "Door"
Prompt.ActionText = "Open"
Prompt.ClickablePrompt = false
Prompt.KeyboardKeyCode = Enum.KeyCode.F
local Table1 = {CFrame = CFrame.new(OpenedValue.Value)}
local Table2 = {CFrame = CFrame.new(ClosedValue.Value)}
local OpenTween = Tween:Create(DoorModel,doortweeninfo,Table1)
local ClosedTween = Tween:Create(DoorModel,doortweeninfo,Table2)
Prompt.Triggered:Connect(function()
if DoorModel:GetAttribute("Opened") == false then
DoorModel:SetAttribute("Opened",true)
OpenTween:Play()
elseif DoorModel:GetAttribute("Opened") == true then
DoorModel:SetAttribute("Opened",false)
ClosedTween:Play()
end
end)
end
for i, v in pairs(Doors) do
setupdoors(v)
end
local function newdoors(Door)
setupdoors(Door)
end
Collection:GetInstanceAddedSignal("Doors"):Connect(newdoors)