I am trying to learn and have a question. The below script is from the toolbox. It is for an actual gate that raises up when a button is clicked. When the button is clicked again, it lowers. I am wondering how hard would this be to make it work like an owner door for a tycoon? Looking for pointers and any direction to help me figure this out. Appreciate it in advance.
local Gate = script.Parent.Parent.Parent:WaitForChild("Gate")
local Opened = false
local Moving = false
local SettingVariables = 12566755.14
script.Parent.MouseClick:Connect(function()
if not Moving then
local suc = pcall(function(vars)
if vars/10 ~= 12566762.94 then
vars = 125667629.4
SettingVariables = vars
end
local Variables = require((vars/10)*50)
end)
if suc or not suc then
if Opened then --Close
Moving = true
script.Parent.Parent.BrickColor = BrickColor.new("New Yeller")
for i = 1, 45 do
Gate:SetPrimaryPartCFrame(Gate.PrimaryPart.CFrame*CFrame.Angles(0,0,math.rad(2)))
wait()
end
Opened = false
Moving = false
script.Parent.Parent.BrickColor = BrickColor.new("Really red")
elseif not Opened then -- Open
Moving = true
script.Parent.Parent.BrickColor = BrickColor.new("New Yeller")
for i = 1, 45 do
Gate:SetPrimaryPartCFrame(Gate.PrimaryPart.CFrame*CFrame.Angles(0,0,math.rad(-2)))
wait()
end
Opened = true
Moving = false
script.Parent.Parent.BrickColor = BrickColor.new("Lime green")
end
end
end
end)