local TweenService = game:GetService("TweenService")
local CollectionService = game:GetService("CollectionService")
local TweenInfo = TweenInfo.new(
1,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0,
false
)
local function PlayOpenAnimation(primaryPart)
local goal = {CFrame = primaryPart.CFrame * CFrame.new(3, 0, 0)}
local tween = TweenService:Create(primaryPart, TweenInfo, goal)
tween:Play()
end
local function PlayCloseAnimation(primaryPart)
local goal = {CFrame = primaryPart.CFrame * CFrame.new(-3, 0, 0)}
local tween = TweenService:Create(primaryPart, TweenInfo, goal)
tween:Play()
end
for _, v in pairs(CollectionService:GetTagged("Desk")) do
local open = v:WaitForChild("Open")
if open then
local Front = open:WaitForChild("Front")
local ProximityPrompt = Front:WaitForChild("Fro"):WaitForChild("Prompt")
if ProximityPrompt then
local primaryPart = Front.PrimaryPart
local isOpen = false
ProximityPrompt.Triggered:Connect(function()
if isOpen then
PlayCloseAnimation(primaryPart)
isOpen = false
print("close desk")
else
PlayOpenAnimation(primaryPart)
isOpen = true
print("open desk")
end
end)
else
warn("[ERROR] Desk")
end
end
end
it only move the front