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

Tycoon Remove button not working ?

Asked by
Bulvyte 388 Moderation Voter
8 years ago

So this is a bit free modelish button but i reedited it and what i want it to do is ontouched it removes the object BUT doesn't buy it. When players enter the game they see the part and they need to remove it with the button, but not buy it.

model = script.Parent.Parent.Parent.Door
Upgradecost = 5

upgradeStuff = model:clone()

wait(1)

model:remove()
owner = script.Parent.Parent.Parent.Parent.Owner
local ting = 0

function onTouched(hit)
    if ting == 0 then
    ting = 1
    check = hit.Parent:FindFirstChild("Humanoid")

    if check ~= nil then
    if hit.Parent.Name == owner.Value then
        local user = game.Players:GetPlayerFromCharacter(hit.Parent)
        local stats = user:findFirstChild("leaderstats")

        if stats ~= nil then
            local cash = stats:findFirstChild("Cash")
            if cash.Value > (Upgradecost-1) then

                cash.Value = cash.Value - Upgradecost
                upgradeStuff.Parent = script.Parent.Parent.Parent.Parent.PurchasedObjects
                script.Parent.Parent:remove()

            end
        end
    end
    end

    ting = 0
    end
end

script.Parent.Touched:connect(onTouched)

i get error: Workspace.Script:2: attempt to index field 'Parent' (a nil value)

Answer this question