How do i repeatedly create parts?

Lately, i’ve enjoyed making pointless creations for entretainment and leaning how to script.
However one of my pointless projects isn’t working properly.
What do i want to achieve? Repeat the part creation every 5 seconds.
What is the issue? The part is only created once.
What solutions have i tried so far? Moving my variables and making while loops. The code below is the code before i moved the variables around and used the loops.

--One-Letter Variables

local w = game.Workspace

local p = Instance.new("Part")

local m = Instance.new("SpecialMesh", p)

local c = w.DogeSpawn

--Two-letter Variables
local dm = "http://www.roblox.com/asset/?id=151778863"

local dt = "http://www.roblox.com/asset/?id=151778895"

local mr = math.random(0, 15000)

local nt = {"The Glorious Doge #", "much name, so doge #", "Teh EPIC Doge #", "Doge #", "Doge Victor Bob David Robert Douglas the ", "cyb3Rd0g3 0f t3H PwNage #"}

--Doge Transformation
m.MeshId = dm

m.TextureId = dt

p.Anchored = false

p.Parent = w

p.CFrame = c.CFrame

p.Name = nt[math.random(#nt)]..mr

Thanks in advance, Sprite.

you could try this:

while wait(5) do
    Instance.new("Part",workspace)
end

edit the code to your likings.

Hm. I’ll try editing it a bit.

But he said he already tried while loops

while wait(5) do
    --One-Letter Variables

local w = game.Workspace

local p = Instance.new("Part")

local m = Instance.new("SpecialMesh", p)

local c = w.DogeSpawn

--Two-letter Variables
local dm = "http://www.roblox.com/asset/?id=151778863"

local dt = "http://www.roblox.com/asset/?id=151778895"

local mr = math.random(0, 15000)

local nt = {"The Glorious Doge #", "much name, so doge #", "Teh EPIC Doge #", "Doge #", "Doge Victor Bob David Robert Douglas the ", "cyb3Rd0g3 0f t3H PwNage #"}

--Doge Transformation
m.MeshId = dm

m.TextureId = dt

p.Anchored = false

p.Parent = w

p.CFrame = c.CFrame

p.Name = nt[math.random(#nt)]..mr
end
1 Like

I dont understand why a while loop wouldn’t work though.

I used while loops on some sections, the loops didn’t work on the sections.

Well, that worked! I was a little scared of using a while loop on the entire script, but i guess that was the problem. Thanks :happy1: