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

How do I make a tycoon part disappear?

Asked by 6 years ago
Edited 6 years ago

Is there any way to fix this so that the dropper keeps dropping every 2 seconds, but blocks that are left on the ground for 10 seconds get deleted?


function drop() Block = Instance.new('Part', workspace) Block.Position = script.Parent.DropPart.Position + Vector3.new (0,-2,0) Block.Name = 'ThingWorf' local worth = Instance.new('NumberValue', Block) worth.Name = "Worth" worth.Value = 5 Block.Size = Vector3.new(1,1,1) wait(10) Block:Destroy() end while true do drop() wait(2) end

1 answer

Log in to vote
0
Answered by
Amiaa16 3227 Moderation Voter Community Moderator
6 years ago

You can use Debris service for this purpose.

function drop()
    Block = Instance.new('Part', workspace)
    Block.Position = script.Parent.DropPart.Position + Vector3.new (0,-2,0)
    Block.Name = 'ThingWorf'
    local worth = Instance.new('NumberValue', Block)
    worth.Name = "Worth"
    worth.Value = 5
    Block.Size = Vector3.new(1,1,1)
    game:GetService("Debris"):AddItem(Block, 10)
end


while wait(2) do
    drop()
end

0
Thank you! ProjectJager 62 — 6y
Ad

Answer this question