Hi, I am working on a script that clones a model in replicated storage and moves it to workspace through a random intvalue number. (Just like miners haven..)

the point is.. it clones the model many times before the int stops at a negative number

This is what happens.. Item from replicatedstorage clones by an intvalue and then goes to workspace while also making that intvalue 0 but instead it becomes -2

here is my script:

game.Players.PlayerAdded:connect(function(player)
local monsters = player:WaitForChild("SaveMonsters")
local tableOfMonstersRetrieved = monsters:GetChildren()
for _, v in pairs(tableOfMonstersRetrieved) do
	local potentialMatch = game.ReplicatedStorage.CharactersLevelOne:FindFirstChild(v.Name)
		wait()
		if v.Value < 1 then
			print("Can't Clone "..v.Name)
		else
			repeat
			if v.Value < 1 then
				print("LESS THAN")
			else
				repeat
					if v.Value < 1 then
						print("finished")
					else
						v.Value = v.Value - 1
					end
						
			wait(0.1)
			if potentialMatch then
				potentialMatch:Clone().Parent = workspace.Monsters
			end
	v.Value = v.Value - 1
		until v.Value < 1
			end
			if v.Value < 1 then
				print("Finished")
			else
				v.Value = v.Value - 1
			end
			v.Value = v.Value - 1
			wait(0.1)
			if potentialMatch then
				potentialMatch:Clone().Parent = workspace.Monsters
			end
		until v.Value < 1
	end
		
end
end)

I need a ton of help on this...

1 comment

0

silence kid