i named them camera1 camera2 etc etc
local cameras = workspace.Cameras:GetChildren();
table.sort(cameras, function(a, b)
if(string.gmatch(a, "%d")[1] and string.gmatch(b, "%d")[1]) then
return string.gmatch(a, "%d")[1] < string.gmatch(b, "%d")[1])
end
end);
local camera = 1;
function nextCamera()
if(camera >= #cameras) then
cameras = 1;
-- move player camera to the camera
end
end
something like this probably, and just put 1-10 in the names of the cameras
local FolderWithInstances=-- your folder
local Sorted={}
for i, v in pairs(FolderWithInstances:GetChildren()) do
local position=string.sub(v.Name,#v.Name,#v.Name)
position=tonumber(position)
Sorted[position]=v
end
for i=1, #Sorted do
local Object=Sorted[i]
-- this object is your camera in correct order
print(Object.Name)
end
I tested it out, and it seems to work.
give it a try
fixed it myself!
local currentpart = 1
local maxcams = 0
for _,v in pairs(cameras:GetChildren()) do maxcams+=1 end
cameraviewer.Activated:Connect(function()
currentpart += 1
if currentpart > maxcams then
currentpart = 1
end
camerapart = cameras:FindFirstChild("Camera"..currentpart)
end)
1 Like
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.