hello ! I tried to make a door using Tween Service and CFrame. I want to precise that the door is a model and not a part (Yes, I welded all the part). The door is anchored. The script :
local doorModel = script.Parent
local doorPrimaryPart = doorModel.PrimaryPart
local TS = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(3)
local goalOpen = {}
local goalClosed = {}
goalOpen.CFrame = doorPrimaryPart.CFrame * CFrame.new(0,0,3)
goalClosed.CFrame = doorPrimaryPart.CFrame
local tweenOpen = TS:Create(doorPrimaryPart, tweenInfo, goalOpen)
local tweenClose = TS:Create(doorPrimaryPart, tweenInfo, goalClosed)
local debounce = false
local isOpened = false
local allowedPlayer = {
"Black_Albi",
}
script.Parent.Click1.ClickDetector.MouseClick:Connect(function(player)
-- if table.find(allowedPlayer, player.Name) then
if debounce == false then
debounce = true
if isOpened == false then
tweenOpen:Play()
tweenOpen.Completed:Wait()
isOpened = true
else
tweenClose:Play()
tweenClose.Completed:Wait()
isOpened = false
end
debounce = false
end
-- end
end)
script.Parent.Click2.ClickDetector.MouseClick:Connect(function(player)
-- if table.find(allowedPlayer, player.Name) then
if debounce == false then
debounce = true
if isOpened == false then
tweenOpen:Play()
tweenOpen.Completed:Wait()
isOpened = true
else
tweenClose:Play()
tweenClose.Completed:Wait()
isOpened = false
end
debounce = false
end
-- end
end)