Loop doesn't work

I want to make that loop works

Issue is loop doesn’t work

local function SpawnCubic()
	
	local Cubic = game.ServerStorage.Cubic
	local ClonedCubic = Cubic:Clone()
	ClonedCubic.Name = "Cubic"
	ClonedCubic.Parent = game.Workspace
	ClonedCubic.Size = Vector3.new(1,1,1)
	ClonedCubic.Position = DropPart.Position
	ClonedCubic.Position = ClonedCubic.Position - Vector3.new(0,1,0)

end

i put this (destroyed = true)

if destroyed == true then
SpawnCubic()
end

image
doesn’t spawn or anything

use a while statement instead of an if statement and add a bit of delay, with task.wait()

Try adding a while statement instead of using:

If statement

Code:

local function SpawnCubic()
	while true do
	    local Cubic = game.ServerStorage.Cubic
	    local ClonedCubic = Cubic:Clone()
	    ClonedCubic.Name = "Cubic"
	    ClonedCubic.Parent = game.Workspace
	    ClonedCubic.Size = Vector3.new(1,1,1)
	    ClonedCubic.Position = DropPart.Position
	    ClonedCubic.Position = ClonedCubic.Position - Vector3.new(0,1,0)
		task.wait(number_here)
	end	
end

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.