I have made a tycoon game where i got owner only door with a button, the button works how it should but the thing i also want there is to make it so only the tycoon owner can press it and make it so it does something, i can show my script there too
local enabled = true
local lasers = script.Parent.Lasers
local button = script.Parent.Button
local ownerValue = script.Parent.Parent.Parent.Values.OwnerValue
button.ClickDetector.MouseClick:Connect(function()
if enabled == true then
enabled = false
lasers.Transparency = 0.8
lasers.CanCollide = false
else
if enabled == false then
enabled = true
lasers.Transparency = 0
lasers.CanCollide = true
end
end
end)
lasers.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if ownerValue.Value ~= player then
if enabled == true then
hit.Parent:FindFirstChild("Humanoid").Health = 0
else
return end
end
end
end)

1 comment
Thank you, this helped me!