I have a minigame server where I was hoping to make a conveyor belt challenge. In the challenge, you run on a conveyor belt with lava blocks with randomly generated sizes being dropped at the beginning of the conveyor belt causing you to have to jump around them to stay on. I have created a conveyor belt, but I have no idea how to make an object that generates a constant flow of lava blocks. Please help!
You can think of this the same way you'd think of scripting a tycoon dropper. A constant loop, cloning an object and placing it. Only differences are:
1) You can't let the conveyor do the work, it will look messy. Parts must be anchored, positioned, and CFramed in a loop.
2) You need to randomize the size, as well as the position.
So, step one.. have a while loop constantly clone a part.
Step 2 .. Randomize the size of the part.
Step 3.. Position the part on the conveyor.
Step 4.. CFrame the part in a loop
Step 5.. Destroy the part when you don't need it anymore.
local part = game.ServerStorage.KillBrick --This is the part template local conveyor = workspace.Conveyor --This is the conveyor local spawnPos = conveyor.Spawn --This is the kill bricks' spawn position local interval = 2; --This is the spawn rate of the kill bricks local lifetime = 20; --This is how long the kill bricks will exist --Reference the conveyor's size to determine the kill brick's possible size local size = conveyor.Size.X while wait(interval) do --Step 1 local c = part:Clone(); c.Anchored = true; --Step 2 c.Size = Vector3.new(math.random(size),c.Size.Y,math.random(1,5)); --Step 3 local dif = size/2 - c.Size.X/2; --Account for side margins c.CFrame = spawnPos.CFrame * CFrame.new(math.random(-dif,dif) or 0,0,0); c.Parent = workspace; spawn(function() local _then = tick(); while wait() do c.CFrame = c.CFrame * CFrame.new(0,0,-.5); --Step 4 local now = tick(); if (now - _then) > lifetime then c:Destroy(); --Step 5 end end end) end
You may see an example of this exact code in action here.