Basically my script loops through a folder and clones a gui for every model found what I want to do is when I click the cloned gui it will clone the model.
Heres my script:
if game:GetService("ReplicatedStorage").Vehicles:FindFirstChildOfClass("Folder"):FindFirstChildOfClass("Model") then
local Path = game:GetService("ReplicatedStorage").Vehicles
for i,v in pairs(Path:GetChildren()) do
if v:IsA("Folder") then
for i, v in pairs(v:GetChildren()) do
if v:IsA("Model") then
local Clone = clonegui:Clone()
Clone.Parent = gui.SpawnProperties.VehiclesFrame.VehicleCloneFrame
Clone.Text.Text = v.Name
end
end
end
end
end
end)
One last question, I see that you’re working with vehicles, so let’s say the model was called car1. The clone’s text would be also car1.
Now that you click on the gui with the name car1, you want the original model, whos name we stole (original car1 model) to be cloned. Right?
if game:GetService("ReplicatedStorage").Vehicles:FindFirstChildOfClass("Folder"):FindFirstChildOfClass("Model") then
local Path = game:GetService("ReplicatedStorage").Vehicles
for i,v in pairs(Path:GetChildren()) do
if v:IsA("Folder") then
for i, v in pairs(v:GetChildren()) do
if v:IsA("Model") then
local Clone = clonegui:Clone()
Clone.Parent = gui.SpawnProperties.VehiclesFrame.VehicleCloneFrame
Clone.Text.Text = v.Name
Clone.MouseButton1Down:Connect(function()
local ModelClone = v:Clone() -- This would be the model's clone
end)
end
end
end
end
end
end)
@Razor_IB’s solution should work. I had a similar idea but was unfortunately AFK for a while. Feel free to mark his reply as the solution if it worked, as I just inserted his code, while he wrote it.