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

Making a droppers brick disappear after 10 seconds??? For tycoon

Asked by 8 years ago

This is the code, can you make it vanish after 10 seconds?

function fire()
    local p = Instance.new("Part")
    p.Position = script.Parent.Position
    p.Size = Vector3.new(1,1,1)
    p.BrickColor = BrickColor.new(106) 
    p.BottomSurface = 0
    p.TopSurface = 0
    p.Name = "TycoonBrick" 
    p.Parent = script.Parent
end 


while true do
    wait(2.5) --Alter Rate Of Drop
    fire()
end
0
Please insert your code into a code block. ChemicalHex 979 — 8y

1 answer

Log in to vote
2
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
8 years ago

You can make it automatically disappear after 10 seconds using the Debris Service:

local deb = game:GetService("Debris")

function fire()
    local p = Instance.new("Part")
    p.Position = script.Parent.Position
    p.Size = Vector3.new(1,1,1)
    p.BrickColor = BrickColor.new(106) 
    p.BottomSurface = 0
    p.TopSurface = 0
    p.Name = "TycoonBrick" 
    p.Parent = script.Parent
    deb:AddItem(p, 10) -- This is the only change necessary.
end 


while true do
    wait(2.5) --Alter Rate Of Drop
    fire()
end

If the Part it already gone (Destroyed or otherwise) when Debris is told to remove it, very simply nothing happens.

0
Thank you so much! albaniankid1 5 — 8y
Ad

Answer this question