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)

3 comments
This is not at all helpful.
Oh wait i found the problem (i think!), I think instead of Cloning it in the first place. Make it clone when onclick, so basically clone the sand/stone/dirt then put it in workspace after clicked
^ I tried that, it put the part where it was before it was placed into ReplicatedStorage