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

Help With Gate For Claim Tycoon Script? Wont Remove Gate. function on touch event broken??..

Asked by 8 years ago
Edited 8 years ago

i cant seem to figure out why my tycoon gate script isn't working? its most likely one of the things you over think but i cant see any errors

local ting = 0
owner = script.Parent.Parent.Parent.OwnerName
function onTouched(hit)
    if ting == 0 then
        ting = 1
        local check = hit.Parent:FindFirstChild("Humanoid")
        if check ~= nil then
            local thisplr = game.Players:FindFirstChild(hit.Parent.Name)
            if (thisplr ~= nil) then
                local ownstyc = thisplr:FindFirstChild("Tycoon")
                if (ownstyc ~= nil) then
                    if ownstyc.Value == 0 then
                        ownstyc.Value = 1
                        owner.Value = thisplr.Name
                        local message = Instance.new("Message")
                        message.Text = "You now own a Tycoon!"
                        message.Parent = thisplr
                        wait(3)
                        message:remove()
                        script.Parent.Parent:remove()
                    elseif ownstyc.Value == 1 then
                        local message = Instance.new("Message")
                        message.Text = "You already own a Tycoon"
                        message.Parent = thisplr
                        wait(3)
                        message:remove()
                    end
                end
            end
        end

    end
end

script.Parent.Touched:connect(onTouched)
0
should the :remove() be change to :Destroy() ??? skillfulzombie88 28 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

":remove()" is wrong. It needs to be ":Destroy()"

local ting = 0
owner = script.Parent.Parent.Parent.OwnerName
function onTouched(hit)
    if ting == 0 then
        ting = 1
        local check = hit.Parent:FindFirstChild("Humanoid")
        if check ~= nil then
            local thisplr = game.Players:FindFirstChild(hit.Parent.Name)
            if (thisplr ~= nil) then
                local ownstyc = thisplr:FindFirstChild("Tycoon")
                if (ownstyc ~= nil) then
                    if ownstyc.Value == 0 then
                        ownstyc.Value = 1
                        owner.Value = thisplr.Name
                        local message = Instance.new("Message")
                        message.Text = "You now own a Tycoon!"
                        message.Parent = thisplr
                        wait(3)
                        message:Destroy()
                        script.Parent.Parent:Destroy()
                    elseif ownstyc.Value == 1 then
                        local message = Instance.new("Message")
                        message.Text = "You already own a Tycoon"
                        message.Parent = thisplr
                        wait(3)
                        message:Destroy()
                    end
                end
            end
        end

    end
end

script.Parent.Touched:connect(onTouched)

Ad

Answer this question