Hello, I’m trying to clone an object a certain number of times. I want to rename it to I
(the number). How do I do that?
Current code:
local val = 0
local user = game.ReplicatedStorage["username"].Value
while wait() do
val = game.Players[user].PartCount.Value
for i = 1,val+1 do
game.Workspace.SamplePart:Clone()
end
end
Thanks in the meantime!
1 Like
You can achive this via concatenation or string formatting. I will give the example
--First Way (concatenation)
for i = 0,10,1 do --looping for 10 times
local NewPart = Instance.new("Part")
local Name = "Part".. i
--more stuff here
local Parent = workspace --Parent it to the workspace
--Second Way (string formatting)
for i = 0,10,1 do
local NewPart = Instance.new("Part")
local Name = string.format("PartName %s",i)
--more stuff here (i use same code to demonstrate)
local Parent = workspace
If you dont really understand string manipulation, go here or go here for string in general
1 Like