Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I make my Owner Only Door work?

Asked by 10 years ago

So I am using Berezaa's Tycoon Kit and I am trying to make a Owner Only Door but there is a small problem. Most Tycoon use a Value named OwnerName but Berezaa uses just Owner. When I use my edited script it does absolutely nothing! My script:

function onTouched(hit)
        local owner = script.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)

When I check it in game the output says this: -- Owner is not a valid member of model --Script'workspace.berezaa's tycoon kit.BrightBlue.pruchases.owner0',Line2 --Stack end -- Disconnected because of exception The script is in a model called OwnerOnlyDoor, the OwnerOnlyDoor model is in purchases and purchases is in the Bright Blue model where the Owner value is in, Please help if you can!

2 answers

Log in to vote
0
Answered by 10 years ago

Your problem is that on line 2, you are missing a .Parent! The parent of the script's parent is actually purchases, but Owner in the Bright Blue model, which is the parent of purchases! The solution to this problem is simply to add another .Parent to the line.

function onTouched(hit)
        local owner = script.Parent.Parent.Parent.Owner --Three parents
        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)

I hope this helps! If you found this answer helpful, you can upvote and accept it!

0
Still doesnt work.. maybe the buttons to open and close is the reason why? TixyScripter 115 — 10y
0
Hmm... take the new script and run it. What does output say? IcyArticunoX 355 — 10y
0
I forgot, I already had that script like that ingame and the stuff I said that it said up at the top is what it says in the output TixyScripter 115 — 10y
0
Try mine DogHouseForMe 0 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

Put your name in the YourName spelled exactly the same.

script.Parent.Touched:Connect(function(hit)
if hit.Parent.Name == "YourName" then --- activates when you touch it
script.Parent.CanCollide = false
script.Parent.Transparency = 0.5
wait(2) --- How long the door is open until it closes
script.Parent.CanCollide = true
script.Parent.Transparency = 0
else
if hit.Parent:FindFirstChild("Humanoid") then
hit.Parent:BreakJoints()
end
end
end)
0
Try mine DogHouseForMe 0 — 5y

Answer this question