Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Parts were cloned too many times?

Asked by 4 years 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
Lakodex 711 Moderation Voter
4 years 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