I have coded something like that (deleted some parts for being clear). I want to make clone a part when player clicked to image button. It just works, it clone 3 parts on origininal with +2 Y position. But it always clone to same position. I want to make them clone always adding +2. Like first clicked added 3 parts to original part +2y +4y +6y and after that when clicked again it should be +8y +10y +12y… but it just stucked on same positions… I hope someone understand that and help me. Thank you.
local originalpart = workspace.Holders.Part
local copy = originalpart:Clone()
local copy2 = originalpart:Clone()
local copy3 = originalpart:Clone()
for i, Button in pairs(script.Parent.AnswerGui.Frame:GetChildren()) do
if not Button:IsA("ImageButton") then continue end
Button.MouseButton1Click:Connect(function()
local answersimg = Button.Image
if string.find(answersimg:lower(), script.Parent.Answer.Value) then
copy.Parent = originalpart.Parent
copy2.Parent = originalpart.Parent
copy3.Parent = originalpart.Parent
copy.CFrame = CFrame.new(originalpart.CFrame.X,originalpart.CFrame.Y+2,originalpart.CFrame.z)
task.wait(0.25)
copy2.CFrame = CFrame.new(originalpart.CFrame.X,originalpart.CFrame.Y+4,originalpart.CFrame.z)
task.wait(0.25)
copy3.CFrame = CFrame.new(originalpart.CFrame.X,originalpart.CFrame.Y+6,originalpart.CFrame.z)
else
--
end
end)
end
local originalpart = workspace.Holders.Part
for i, Button in pairs(script.Parent.AnswerGui.Frame:GetChildren()) do
if not Button:IsA("ImageButton") then continue end
Button.MouseButton1Click:Connect(function()
local answersimg = Button.Image
if string.find(answersimg:lower(), script.Parent.Answer.Value) then
local copy = originalpart:Clone()
local copy2 = originalpart:Clone()
local copy3 = originalpart:Clone()
copy.Parent = originalpart.Parent
copy2.Parent = originalpart.Parent
copy3.Parent = originalpart.Parent
copy.CFrame = CFrame.new(originalpart.CFrame.X,originalpart.CFrame.Y+2,originalpart.CFrame.z)
task.wait(0.25)
copy2.CFrame = CFrame.new(originalpart.CFrame.X,originalpart.CFrame.Y+4,originalpart.CFrame.z)
task.wait(0.25)
copy3.CFrame = CFrame.new(originalpart.CFrame.X,originalpart.CFrame.Y+6,originalpart.CFrame.z)
originalpart = copy
else
--
end
end)
end
You’re only adding, there’s no check to change the position values on another click. By doing this, it’ll repetitively stack if you click the button.