I was making a mini project, while i was making this script, i noticed that the random spawn generator was working, but not the way i wanted it to work.
How i wanted it to work was so that everytime it generates a new position after the first block has spawned.
Randomnumber = math.random(1,750)
while true do
wait()
goldplate = Instance.new("Part",game.Workspace)
goldplate.Position = Vector3.new(Randomnumber,Randomnumber,Randomnumber)
goldplate.BrickColor = BrickColor.new("Gold")
goldplate.Anchored = false
goldplate.Material = "Metal"
wait(4.5)
end
while true do
local randompos = math.random(1,750)
local goldplate = Instance.new("Part",game.Workspace)
goldplate.Position = Vector3.new(randompos,randompos,randompos)
goldplate.BrickColor = BrickColor.new("Gold")
goldplate.Anchored = false
goldplate.Material = "Metal"
task.wait(4.5)
end
task.wait() is just more reliable than wait(). It can withstand lag and still wait the correct amount. Naturally, it will be slightly faster than the older method.