Turn a gate into an owner door

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)
1 Like

Simply check if the character’s player.UserId is equal to the tycoon’s owner, if it is then do the opening function.

Not about the door, but there is a random require that seems to be trying to make it less suspicious by creating a random “SettingVariables” variable, “vars” variable and “Variables” variable. The script requires, for whatever reason, a module script with the id (vars/10) * 50. Maybe I’m wrong but it just seems like a red flag

Thank you for pointing this out. I will look into something else or trying to make my own gate that raises for owner base. I need more practice anyways it seems.

1 Like

Thank you as well. I will look into this more and figure out how to add it once I figure out how to make a gate.

1 Like

This seems a bit off topic. Consider moving to private messages.

1 Like

Thank for the info.
Deleting teh message.

1 Like