So I am using Berezaa's Tycoon kit and I have been making a owner only door and I don't know what is wrong with the script. The script has 3 Parents OwnerOnlyDoor, then Purchases, and then there is Bright Blue where there is a Owner Value. That means there is 3 Parents so I edited it to three parents and also the Value is called Owner not OwnerName so I changed that to Owner and it still wont work. It may be because the type of value the Owner is a Object Value idk. If you can help me out please!!! My script:
function onTouched(hit) local owner = script.Parent.Parent.Parent.Owner local h = hit.Parent:findFirstChild("Humanoid") if (h ~= nil) then if h.Parent.Name == owner.Value then script.Parent.CanCollide = false wait(2) script.Parent.CanCollide = true else h.Health = 0 end end end script.Parent.Touched:connect(onTouched)
THANKS!
Your code would work, if it were a StringValue. But, "Owner" is an ObjectValue, not a StringValue.
The way his tycoon kit is coded, it saves the actual player to the Owner value. So you need to locate the player.
In order to do this, inside the touched function, instead of searching for the humanoid, search for the player from the character.
TIP Don't set the CanCollide by the script. Just have it set to false in the first place. If it's the owner, they'll just pass right through and the code will do nothing. Otherwise, it'll kill them. This is what I did in my code here:
local owner = script.Parent.Parent.Parent:WaitForChild("Owner") script.Parent.Touched:connect(function(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) -- If it's not a player's character, it won't break. if player then -- Checks if a player exists from that character. -- Now look for the humanoid, now we know it's there because we know for sure it's a player character. local human = hit.Parent:findFirstChild("Humanoid") -- It's there for sure. -- Might as well double check. if human and player ~= owner.Value then -- If it's not the owner, kill them! human.Health = 0 end end end)