Can you concatenate strings inside of a script?

I am trying to make a simpler system for this script. `local button = script.Parent
local num = script.Num

local cameras = 3

local number = cameras+1

button.MouseButton1Down:Connect(function()
num.Value = num.Value+1
local nume = num.Value
if num.Value == number then
print(num.Value)
num.Value = 1
end
if num.Value == 1 then
local cc = workspace.CurrentCamera
cc.CameraType = Enum.CameraType.Scriptable

	workspace.CurrentCamera.CFrame = game.Workspace.Cameraone.CFrame
	print(num.Value)
end

if num.Value == 2 then
	local cc = workspace.CurrentCamera
	cc.CameraType = Enum.CameraType.Scriptable
	
	workspace.CurrentCamera.CFrame = game.Workspace.Cameratwo.CFrame
	print(num.Value)
end

if num.Value == 3 then
	local cc = workspace.CurrentCamera
	cc.CameraType = Enum.CameraType.Scriptable

	workspace.CurrentCamera.CFrame = game.Workspace.Camerathree.CFrame
	print(num.Value)
end
if num.Value == 3 then
	local cc = workspace.CurrentCamera
	cc.CameraType = Enum.CameraType.Scriptable

	workspace.CurrentCamera.CFrame = game.Workspace.Camera..nume.CFrame
	print(num.Value)
end

end)`

if you look at the 3rd last line of my script you can see this line of code " workspace.CurrentCamera.CFrame = game.Workspace.Camera…nume.CFrame" can you make a string inside a code?

if you need more information please ask me.

I’m assuming you wanted something like this?

workspace.CurrentCamera.CFrame = game.Workspace["Camera"..num.Value].CFrame

Ahhhh yes thank you! i didnt know you needed []

1 Like