This is a script from an owner only door, but there are aliens in my game that I would like to be killed from the lasers too. I tried deleting the "plr" part so that it would just set all humanoids health to zero ,and I tried just identifying an alien also as a plr by using
game. Aliens.("Alien")
but that didn't work either. I am new to scripting so sorry if I am doing this completely wrong, but what is the most efficient way of doing this?
val = script.Parent.Parent.Parent.Value
function touc(part)
local plr = game.Players:FindFirstChild(part.Parent.Name)
if plr then
local h = part.Parent:FindFirstChild("Humanoid")
if h then
if val.Value == true then
if part.Parent.Name ~= script.Parent.Parent.Parent.Parent.Parent.Owner.Value.Character.Name then
h.Health = 0
end
end
end
end
end
script.Parent.Touched:connect(touc)

21 comments
says that owner is not a valid member of folder, but I think I need to have the plr part because I think it makes sure that only the owner can walk through.
Are you sure script.Parent.Parent.Parent.Parent.Parent.Owner.Value.Character.Name is a thing? That was from your code that i just copied assuming it was correct.
yes it worked beforehand. I think it makes sure that the owner won't take damage...
yes, that is the goal. The way we should be doing that is... Check if the person's name is the same as the name of the Owner.
However, the error you are getting is saying that script.Parent.Parent.Parent.Parent.Parent (Does not lead to an object called "Owner")
follow through your explorer and tell me what script.Parent.Parent.Parent.Parent.Parent is
Ok...the first parent is the pipe in which the script is in, second is the lasers in which the set of pipes are in, third is th owner only door that the lasers are a part of, fourth is the purchases that the owner only door is a part of, fifth is the tycoon it is in. Then it finds the Owner Value in the tycoon. That is set to change to whoever owns the tycoon
so is the main parent of the tycoon a folder? because that's what it says the 5th parent is. And once it gets there, it looks for an object called "Owner" and says it cannot find it.
yes
Also, is the "Owner" object a StringValue, ObjectValue, etc?
Look through it again and make sure "Owner" is in that folder, and not in a child of that folder
owner is directly is that folder and what is a String or Object Value? Sorry, I'm new
nvm I found it... Object Value
is Owner capitalized?
yup
Man, i would love to help this further but if the error is saying that owner is not a valid member of folder, then something must be wrong with that line.
when you play the game open up that tycoon (while actually playing) and see if there is an "Owner" in the tycoon cause the error says it aint there
alright I just figured out the problem: when I was testing it I just ungrouped the purchased model so that I could skip right to the end of the tycoon instead of having to go through the whole thing because I have a script that removes everything in the purchases model but puts it back when it is bought. by doing this, I broke your beautiful script with my blindness.
I tested it and it works great sorry for wasting your time...
Hahaha no worries, I'm glad you found out what happened though! Good job. If I helped at all with the original code would you mind accepting the answer?
of course