So I made this script with my door. It opens nice, and it closes nice. Tho after doing each thing once I can't do it anymore. I believe I need it to repeat or something but have no idea how to do it on the script. Any help is appreciated :)
--//Variables
local Door = script.Parent.Parent
local Main = Door.Main
local Button = script.Parent
local DoorOpen = Door.Sounds:WaitForChild("DoorOpen")
--//Opening and Closing
local Opened = false
Button.ClickDetector.MouseClick:connect(function()
if Opened == false then
Opened = true
DoorOpen:Play()
for i = 0,3,.1 do
Door:SetPrimaryPartCFrame(Door:GetPrimaryPartCFrame() * CFrame.Angles(0,math.rad(math.pi/1),0))
wait()
end
end
end)
wait(3)
local Opened = true
Button.ClickDetector.MouseClick:connect(function()
if Opened == true then
Opened = false
DoorOpen:Play()
for i = 0,3,.1 do
Door:SetPrimaryPartCFrame(Door:GetPrimaryPartCFrame() * CFrame.Angles(0,-math.rad(math.pi/1),0))
wait()
end
end
end)

1 comment
Try printing Opened and see what it equals, also it may be because you are spamming the click detector