I made this sliding door model for a game Im making for fun but what is bugging me is that the whole door wont move only the primarypart
Would i have to weld it or something?
local door = script.Parent.Parent.Door
local sound = door.Sound
local status = script.Parent.Status
local ClickDetector = script.Parent.ClickDetector
local TweenService = game:GetService("TweenService")
local primaryPart = door.PrimaryPart
local OpenCFrame = primaryPart.CFrame
local CloseCFrame = OpenCFrame * CFrame.new(0, -7, 0)
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut)
local DoorOpen = TweenService:Create(primaryPart, tweenInfo, {CFrame = OpenCFrame})
local DoorClose = TweenService:Create(primaryPart, tweenInfo, {CFrame = CloseCFrame})
local debounce = false
ClickDetector.MouseClick:Connect(function()
if not debounce then
debounce = true
if status.Value == "CLOSED" then
DoorOpen:Play()
sound:Play()
status.Value = "OPEN"
elseif status.Value == "OPEN" then
DoorClose:Play()
sound:Play()
status.Value = "CLOSED"
end
task.wait(tweenInfo.Time)
debounce = false
end
end)