Hello, I am having problems with my Owner Only Door script. I have buttons for it that Change the color of the Door, One is open which changes it to Lime green (open for others to get in) and the other is close which makes it red (not open for others to get in) I have this script to make it work with the colors so if someone passes through it when its red they die but if green they live.
script.Parent.Touched:connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if game.Players:GetPlayerFromCharacter(hit.Parent) then
if script.Parent.BrickColor == BrickColor.new("Lime green") then
print("passed safely")
elseif script.Parent.BrickColor = BrickColor.new("Really red") then
if player ~= Owner then
hit.Parent:BreakJoints()
end
print("you shall not pass")
end
end
end
end)
I wanted to edit this script so that if you are the owner of the tycoon you can pass through the door even if it is open or closed and this is what I ended up with.
local owner = script.Parent.Parent.Parent.Parent:WaitForChild("Owner")
script.Parent.Touched:connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent) -- If it's not a player's character, it won't break.
if player then -- Checks if a player exists from that character.
-- Now look for the humanoid, now we know it's there because we know for sure it's a player character.
local human = hit.Parent:findFirstChild("Humanoid") -- It's there for sure.
-- Might as well double check.
if human and player ~= owner.Value then -- If it's not the owner, kill them!
else
script.Parent.Touched:connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if game.Players:GetPlayerFromCharacter(hit.Parent) then
if script.Parent.BrickColor == BrickColor.new("Lime green") then
print("passed safely")
elseif script.Parent.BrickColor = BrickColor.new("Really red") then
if player ~= Owner then
hit.Parent:BreakJoints()
end
print("you shall not pass")
end
end
end
end)
The problem is that when I use this others can also pass through whether Red or green even if there not the tycoon owner. If you edit it please make sure the Owner of the tycoon can still pass through no matter what. Also the Owner value is changed as a person joins the tycoon. Please help! All answers/feedback is appreciated!

1 comment
Your Question is Vague; What is the problem? What isn't working about it? Was there any Errors that came into the Output? If so, what did it say? Was there a Red line under any code? Did the Script Analysis (if enabled) pick up anything? If so, what did it say? These Questions are important so we can answer your Question (so we understand, and can prepare to answer).