Making an unspecified amount of clones of one object

I am trying to recreate the flamethrower from the classic brickbattle games and I’ve got it to clone a part but it just keeps repositioning the same clone
So basically I need to make many clones of one part
this is my current code

tool = script.Parent
on = false
spoor = tool.Handle.gas
counter = tool.Handle.SurfaceGui.TextLabel.Text

 flames = game.ReplicatedStorage.flava:Clone()
ammo = 200
tool.Activated:Connect(function()
	if on == false then
		on = true
		repeat
			boom()
			task.wait()
		until on == false 
		print(on)
	elseif on == true then
		on = false
		print(on)
	end
end)
tool.Unequipped:Connect(function()
	on = false
end)

tool.Activated:Connect(function()
	
	
		
	
	
	
end)
flames.Touched:Connect(function(guy)
	if guy:IsA("Humanoid") then
		guy.Health -= 8
	end
	
end)

function boom()
	if ammo > 1 then
			
	

	flames.Color = Color3.fromRGB(math.random(160,255), math.random(60,100),0)
	flames.Position = spoor.Position
	flames.Orientation = spoor.Orientation
			flames.Parent = workspace
			ammo -= 1
			tool.Handle.SurfaceGui.TextLabel.Text = ammo
		wait(.1)
		end
		
		
	end
	
	

also the damage part doesn’t work but dslkfjsdklfsdkhfohefhrgjk

2 Likes
tool = script.Parent
on = false
spoor = tool.Handle.gas
counter = tool.Handle.SurfaceGui.TextLabel.Text
ammo = 200
tool.Activated:Connect(function()
	if on == false then
		on = true
		repeat
			boom()
			task.wait()
		until on == false 
		print(on)
	elseif on == true then
		on = false
		print(on)
	end
end)
tool.Unequipped:Connect(function()
	on = false
end)

tool.Activated:Connect(function()
	
	
		
	
	
end)

function boom()
	if ammo > 1 then		
        local flames = game.ReplicatedStorage.flava:Clone()

        flames.Touched:Connect(function(guy)
            if guy:FindFirstChildOfClass("Humanoid") then
                guy.Health -= 8
            end
        end)

	    flames.Color = Color3.fromRGB(math.random(160,255), math.random(60,100),0)
	    flames.Position = spoor.Position
	    flames.Orientation = spoor.Orientation
	    flames.Parent = workspace
	    ammo -= 1
	    tool.Handle.SurfaceGui.TextLabel.Text = ammo
        task.wait(.1)
	end
end
2 Likes

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