So I have a Owner Only Door with multiple doors so its like a Jail cell. I have buttons that turn it on and off that change the colors but they don't change the script to allow the others in.
Owner Only Door script:
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!
human.Health = 0
end
end
end)
Open button script:
function onClicked()
local Model = script.Parent.Parent
Model.OwnerOnlyDoor.BrickColor = BrickColor.new("Lime green")
Model.OwnerOnlyDoor2.BrickColor = BrickColor.new("Lime green")
Model.OwnerOnlyDoor3.BrickColor = BrickColor.new("Lime green")
Model.OwnerOnlyDoor4.BrickColor = BrickColor.new("Lime green")
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
Close button script:
function onClicked()
local Model = script.Parent.Parent
Model.OwnerOnlyDoor.BrickColor = BrickColor.new("Really red")
Model.OwnerOnlyDoor2.BrickColor = BrickColor.new("Really red")
Model.OwnerOnlyDoor3.BrickColor = BrickColor.new("Really red")
Model.OwnerOnlyDoor4.BrickColor = BrickColor.new("Really red")
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
Please help me make it to where it activates the Owner only door scrip on close but deactivates it on opening. For example in other games when people hit the open button other people can walk through without dying but are allowed into your base, with my script it only changes the color of the Owner Only door when you click it but it doesn't allow people in without dying. Then for the close button I want it to revert it back to making others die as they walk in/out.

2 comments
Where do I put this script?
the door now can you accept this and upvote it maybe?