I have a script that creates numbered objects with the name "p2loc1clone"..X, where x is the order in which the objects where created. When clicking on the created object, a string value stored in the player called PlayerControl changes to represent which object being controlled by the player (the exact details aren't super important for the question I'm asking). The loop I'm trying to use is as follows:
local p2 = script.Parent.Board.PlayerPart2Loc1 local y = 0 local clone = "empty" for i=1,50 do if playerControl == "p2loc1clone"..i then y = i clone = p2.p2loc1clone..[i] end end
it seems to work until clone = p2.p2loc1clone..[i] is reached. Basically I'm trying to add the loop's number to the end of the definition for clone, which is the object path of a real part in the workspace. My problem is the exact syntax which I can't seem to find anywhere. I'm not sure if concatenating anything but a string can be done in Roblox Lua, but I would appreciate help.