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.
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 hit.Parent:BreakJoints() print("you shall not pass") end end end end)
script.Parent.openclick.MouseClick:connect(function(plr) --turn bricks into green end) script.Parent.closeclick.MouseClick:connect(function(plr) --turn bricks into red end) 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 hit.Parent:BreakJoints() print("you shall not pass") end end end end)