I'm trying to fix my owner only doors issue that kills the regular player(not the owner of tycoon) even though the door is opened and everyone can get in. My code:
local Players = game:GetService("Players")
local enabled = true
local lasers = script.Parent.Lasers
local button = script.Parent.Button
local ownerValue = script.Parent.Parent.Parent.Values.OwnerValue
lasers.CanCollide = false
button.ClickDetector.MouseClick:Connect(function(playerWhoClicked)
if ownerValue.Value == playerWhoClicked then
if enabled == true then
enabled = false
lasers.Transparency = 0.8
else
enabled = true
lasers.Transparency = 0
end
end
end)
-- The lasers(thing im tryna fix)
lasers.Touched:Connect(function(hit)
if hit.Parent:FindFirstChildOfClass("Humanoid") then
local player = Players:GetPlayerFromCharacter(hit.Parent)
if ownerValue.Value ~= player then
hit.Parent:FindFirstChild("Humanoid").Health = 0
end
end
end)
