Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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)

1 comment

0

should the :remove() be change to :Destroy() ???

1 answer

✓ Accepted answer

":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)

This discussion is preserved as it was. New answers, comments, and votes are closed.