Invalid argument #3 (string expected, got nil)

What is the issue: I am trying to get a string value from a folder and then changing the text of a text label. The issue however the output says something like: invalid argument #3 (string expected, got nil)

More info:
Code:

local tweenservice = game:GetService(“TweenService”)
local section1 = 1
local section2 = 1
local state = 1
local function changecameratype(scriptable,custom)
if scriptable == true then
repeat
game.Workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
until game.Workspace.CurrentCamera.CameraType == Enum.CameraType.Scriptable
elseif custom == true then
repeat
game.Workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
until game.Workspace.CurrentCamera.CameraType == Enum.CameraType.Custom
end
end
local function moveobject(TIME,OBJECT,OBJECTTO,STYLE,DIRECTION)
tweenservice:Create(OBJECT,TweenInfo.new(TIME,STYLE,DIRECTION),{CFrame = OBJECTTO.CFrame})
end
local function NEXT()
if state == 1 then
changecameratype(true,false)
game.Workspace.CurrentCamera.CFrame = game.Workspace.Selection:FindFirstChild(section1).Camera.CFrame
script.Parent.TopName.Text = game.Workspace.Selection:FindFirstChild(section1).PackName.Value
elseif state == 2 then
changecameratype(true,false)
game.Workspace.CurrentCamera.CFrame = game.Workspace.Selection:FindFirstChild(section1):FindFirstChild(section2).Camera.CFrame
script.Parent.TopName.Text = game.Workspace.Selection:FindFirstChild(section1).PackName.Value
end
end
local function PRE()

end
local function SELECT()
if state == 1 then
state = 2
changecameratype(true,false)
moveobject(2,game.Workspace.CurrentCamera,game.Workspace.Selection:FindFirstChild(section1)[“1”].Camera,Enum.EasingStyle.Quad,Enum.EasingDirection.In)
game.Workspace.CurrentCamera.CFrame = game.Workspace.Selection:FindFirstChild(section1)[“1”].Camera.CFrame
print(section2)
print(section1)
script.Parent.TopName.Text = game.Workspace.Selection[section1][section2].Name.Value
end
end
script.Parent.Frame.Next.MouseButton1Click:Connect(NEXT)
script.Parent.Frame.Pre.MouseButton1Click:Connect(PRE)
script.Parent.Frame.Select.MouseButton1Click:Connect(SELECT)

Screen:
Coming Soon - Roblox Studio 6_21_2020 11_48_51 AM (2)

1 Like

What line is throwing the error

Never mind I think I found out, you named the value as the property “Name”. So it tries to find the name.Value. that is nil. Maybe change the name value to something else, or use FindFirstChild.

I think you can do this instead:

script.Parent.TopName.Text = game.Workspace.Selection[section1][section2]:FindFirstChild("Name").Value

That way it looks for the child and not property.

1 Like

Oh yea I did not think about that. Let me go check now.

1 Like

Yup it worked, I forgot about the name property.

1 Like

Great! Please mark my answer as a solution then :slightly_smiling_face:

I did :slight_smile: CHAR30000000000000000000

1 Like