Duplicate models that have functions in StarterGUI?

Ok I will re-make the whole script and share you the final script.

If you want to eliminate them you can do what ChiefWildin has explained to you, but if you do not want to eliminate them and want to leave them free, to avoid cloning them again, since you said you wanted to reset them.
You can do this:

game.Players.PlayerRemoving:Connect(function(plr)
	local primaryParts = game.Workspace:FindFirstChild(plr.Name .. "_primaryParts")
	local secondaryParts = game.Workspace:FindFirstChild(plr.Name .. "_secondaryParts")
	
	if primaryParts then
		primaryParts.Name = "empty_primaryParts"
	end
	if secondaryParts then
		secondaryParts.Name = "empty_secondaryParts"
	end
end)

In this case, you should make when a player connects, the server chooses an ‚Äúempty_primaryParts‚ÄĚ and an ‚Äúempty_secondaryParts‚ÄĚ, and rename it to the player‚Äôs name followed by ‚Äú_primaryParts‚ÄĚ and ‚Äú_secondaryParts‚ÄĚ

I would also add this right?

folder=Instance.new("Folder")
folder.Name=player.Name.."_primaryParts"
folder=Instance.new("Folder")
folder.Name=player.Name.."_secondaryParts"

You can do that, but the folder would be empty.
You are forgetting something, you must do this:

local folder = Instance.new("Folder", game.Workspace)

Yes but I would have to add a script where it renames the file to that.

Would this potentially work?
Before player buys the model in game it will be named as empty_primaryParts and empty_secondaryParts. But when they buy it, the folders will be renamed to player.Name‚Ķ‚Äú_primaryParts‚ÄĚ and player.Name‚Ķ‚Äú_secondaryParts‚ÄĚ and I could add a if statement where if the folders name = player.Name‚Ķ‚Äú_primaryParts‚ÄĚ then they can make changes.

I’m currently using something exactly like that. The only difference is that I am using it with car spawners on a race track. When a player enters the game, the server searches for an empty spawner and assigns it to the player, and is reserved for him throughout the game.

Yes, that is similar, the only difference would be: For my plan, they would need to buy the model to use it, and they do not get self-assigned.

So the only thing you have to change is that, instead of the server assigning the player the folders when connecting, you do it when they buy the product.

Yes so I might have files named empty_primaryParts1 empty_primaryParts2 and so on.

Thanks for all of your help, I will come back when needed. I also added you back on roblox, if you have discord also you can add me: rete#0001 !

1 Like

Having the numbered folders would make you have to extend your code much more. Leave them all as ‚Äúempty_primaryParts‚ÄĚ and ‚Äúempty_primaryParts‚ÄĚ. Using FirstFirstChild() the server will only select one.

In this case you could do the following:
Suppose you have all the folders, within a master folder.

script.Parent.BuyButton.MouseButton1Click:Connect(function(plr)
	local masterFolder = game.Workspace.MasterFolder
	local empty_primaryParts = masterFolder:FindFirstChild("empty_primaryParts")
	local empty_secondaryParts = masterFolder:FindFirstChild("empty_secondaryParts")
	
	if empty_primaryParts ~= nil and empty_secondaryParts ~= nil then -- If it is not nil, it means that the server found an empty one.
		empty_primaryParts.Name = plr.Name .. "_primaryParts"
		empty_secondaryParts.Name = plr.Name "_secondaryParts"
	end
end)
1 Like