My script is supposed to put different blocks in different places. As of now, if x, y, or z equal the same thing (for example, if x and y both are 1), then it will only clone the first one that shows up. Why is this?
part = script.Parent dirt = game.ReplicatedStorage:FindFirstChild("dirt"):Clone() stone = game.ReplicatedStorage:FindFirstChild("stone"):Clone() sand = game.ReplicatedStorage:FindFirstChild("sand"):Clone() function onClick() local x = math.random(3) if x == 1 then dirt.Parent = workspace dirt.Position = part.Position + Vector3.new(4,0,0) end if x == 2 then stone.Parent = workspace stone.Position = part.Position + Vector3.new(4,0,0) end if x == 3 then sand.Parent = workspace sand.Position = part.Position + Vector3.new(4,0,0) end local y = math.random(3) if y == 1 then dirt.Parent = workspace dirt.Position = part.Position + Vector3.new(0,4,0) end if y == 2 then stone.Parent = workspace stone.Position = part.Position + Vector3.new(0,4,0) end if y == 3 then sand.Parent = workspace sand.Position = part.Position + Vector3.new(0,4,0) end local z = math.random(3) if z == 1 then dirt.Parent = workspace dirt.Position = part.Position + Vector3.new(0,0,4) end if z == 2 then stone.Parent = workspace stone.Position = part.Position + Vector3.new(0,0,4) end if z == 3 then sand.Parent = workspace sand.Position = part.Position + Vector3.new(0,0,4) end print(x) print(y) print(z) part:Destroy() end part.ClickDetector.MouseClick:connect(onClick)
you do realised, you should have use
x = math.random(1,3) if x == 1 then -- Do something elseif x == 2 then -- Do something else elseif x == 3 then -- Do this thing end
Welp, hope this help!