New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

Parts were cloned too many times?

Asked by 14 days ago

I have problem with cloning beacuse when script is executing it clones 3 or 2 block's in same place more than it's schould

~~~~~~~~~~~~~~~

    while true do
local x = math.random(0,3)
local pos = script.Parent.PositionOfBlocks.Value
script.Parent.PositionOfBlocks.Value = script.Parent.PositionOfBlocks.Value + 4
if x <= 2.8 then
    local grass = game.ReplicatedFirst.Generate.BlockOfGrass:Clone()
    grass.Parent = game.Workspace
    grass.Position = script.Parent.Position + Vector3.new(pos,0,0)



else
        local coal = game.ReplicatedFirst.Generate.BlockOfStone:Clone()
    coal.Parent = game.Workspace
    coal.Position = script.Parent.Position + Vector3.new(pos,0,0)

end
if (script.Parent.Name == "BasicBlock")then
 local clone = script.Parent:Clone()> 
 clone.Parent = game.Workspace
 clone.Position = script.Parent.Position + Vector3.new(0,0,pos)
 clone.PositionOfBlocks.Value = 0 
 clone.Name = ("ClonedCloner")
 end

 wait()
     end

~~~~~~~~~~~~~~~~~ No Errors :

1 answer

Log in to vote
0
Answered by 14 days ago

Instead of While true do use for i = 1,HowManyTimes do. Use below and copy and paste your above script.

for i = 1,10 do --This will repeat 10 times
wait()
--Put the code you want here to do it that many times.
end
Ad

Answer this question