Imagine you have a working owner only door with a button and lasers right? but you wanna stop other players who dont own the tycoon from opening the door with the button when new people are tying to build there tycoon.
How would this work? or How would you write this out in code to do those types of checks?
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
Lasers.Transparency = 0
Lasers.CanCollide = true
Enabled = true
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)
this is my code so far

1 comment
Wow, thank you so much that really helps out a lot to know what i'm doing work and what im not. Again Amazing job and thank you for the help!