SmakToj
(SmakToj)
December 31, 2023, 3:12am
#1
Hello!
I’m trying to create a system where every 5 seconds a part spawns. It works perfectly fine without the while true loop. However when I add a while true loop it spawns twice and then just stops. Here is what happens without the loop:
local part = Instance.new("Part")
part.Name = "jeff"
part.Shape = Enum.PartType.Ball
part.Material = Enum.Material.Neon
part.BrickColor = BrickColor.new("Really red")
part.Size = Vector3.new(25.8, 25.8, 25.8)
part.Position = Vector3.new(0.45, 351.564, -1566.319)
part.Parent = workspace
Instance.new("NumberValue", workspace)
wait(5)
But when I add the loop…
while true do
local part = Instance.new("Part")
part.Name = "jeff"
part.Shape = Enum.PartType.Ball
part.Material = Enum.Material.Neon
part.BrickColor = BrickColor.new("Really red")
part.Size = Vector3.new(25.8, 25.8, 25.8)
part.Position = Vector3.new(0.45, 351.564, -1566.319)
part.Parent = workspace
Instance.new("NumberValue", workspace)
wait(5)
end
It doesn’t work as intended.
Any help is appreciated!
1 Like
where’s the script at with the loop in it?
SmakToj
(SmakToj)
December 31, 2023, 3:16am
#3
the script is in a random part at the location of the where the part spawns
Can you show us the full script. We need more information. I believe your while loop has no problem.
Is there any error?
SmakToj
(SmakToj)
December 31, 2023, 3:24am
#5
That is the whole script. There is nothing else.
Is it the only script that spawns “jeff”? It doesn’t make sense that two “jeff” spawn almost simultaneously.
SmakToj
(SmakToj)
December 31, 2023, 3:34am
#7
Nah it’s not that. I solved it. Basically the script was in a part which I was using to reference where I wanted to spawn it in. And the part was not anchored so it kept falling off the map
Thanks anyways!
1 Like
Good job solving it by your own!
But I recommend you to put the script in “ServerScriptService” if it’s a server script
1 Like
system
(system)
Closed
January 14, 2024, 3:37am
#10
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.