So, I’m trying to make an owner-only door for a tycoon that when it’s activated only lets the owner of the tycoon pass through and can be activated and deactivated.
The activation part works just fine, but the when it is activated it gives a nil on .Value on the FindFirstChild(“Tycoon”) line. Would that part need to be in a LocalScript to work? (Tycoon is an ObjValue in the player)
Here’s the code.
function kill(player)
local players = game:GetService("Players")
local button = script.Parent.Button
if script.Parent.Activated.Value == true
and player.Parent:FindFirstChild("Humanoid")
--error here on value \/
and player:FindFirstChild("Tycoon").Value ~= script.Parent.Parent then
print("attempted to kill " .. player.Parent.Name)
local character = player.Parent
local human = character.Humanoid
if human then
print("Player killed!")
human.Health = 0
player.Character:BreakJoints()
end
end
end
function activate(plr)
if plr:FindFirstChild(“Tycoon”).Value == script.Parent.Parent then
if script.Parent.door.Transparency == 0.5 then
print("door de-activated")
script.Parent.Activated.Value = false
script.Parent.door.Transparency = 0.85
else
print("door activated")
script.Parent.door.Transparency = 0.5
script.Parent.Activated.Value = true
end
end
end
script.Parent.Button.ClickDetector.MouseClick:Connect(activate)
script.Parent.door.Touched:Connect(kill)
Did you create the Tycoon object on the server? If “Tycoon” doesn’t exist on the server then that will error. Its better to put findfirstchild in a previous and statement, since if it somehow doesn’t exist it will error.
I am probably gonna be giving out false information as I am not a scripter and I was never interested in making the type of tycoon you are making here, but what I would try to do is write the script in a way that it would find the owner of that tycoon, so let’s say it is the Blue team, you would only let people who are on the Blue team to have collisions turned off on that Owner Only Door, and for everyone else, collisions would be turned on with that door. And the door when turned on would have the script that would kill the player upon contact.
That is just me, you will most likely have to ask someone else because I for sure ain’t a scripter
… or he could just keep collisions off and kill any players who decide to try and walk through???
He could also add a big block inside that fills the entire interior and detects if touched and will kill them instead (so noclip wont work??) but only make that if the entire place is finished and you dont need to move things around.
That’s the problem then, the server can’t see things created by the client. You can probably try creating the tycoon object on the server instead, which will fix the door.