Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Attempt to concatenate local 'Name' (a nil value)?

Asked by 8 years ago

Alright so I am making a computer GUI for my Homeland Security agency within a government group it includes a Login screen,windows, screen and some programs under the start menu and it has given me an error which I will include my code a picture of the explorer and also a picture of the error it has given me.

-- Login script



wait(0.1)

ap = require(game.Workspace.TrelloAPI)
BoardID = "IQtYgu2z"
ListID = ap:GetListID("Computer Logins",BoardID)



local player = script.Parent.Parent.Parent.Parent.Parent
local userid = player.UserId
local db = false
local placeid = game.PlaceId


script.Parent.MouseButton1Click:connect(function()
    if not db then
    db = true

    local Rank = script.Parent.Parent.Rank.Text
    local Name = script.Parent.Parent.Name.Text 
    local Code = script.Parent.Parent.Code.Text 

    script.Parent.Text = "Please wait"

    CardID = ap:AddCard("Computer Login By: "..player.Character.Name.." || ID: "..userid,"**Rank:** "..Rank.."\n\n**Name:** "..Name.."\n\n**Entered Code:** "..Code.."",ListID)

if Code == "1497" then
    script.Parent.Parent.Visible = false
    script.Parent.Parent.Parent["Windows Frame"].Visible = true
elseif Code > "1497" or Code < "1497" then
    Code = "Incorrect Code"
       end
    end
end)

Picture of the error: https://gyazo.com/0db1add23f2c41c3d677f3fed4d87b13

Picture of the explorer: https://gyazo.com/cec5d1c4d5a91559e6e8f066f0e5959c

1 answer

Log in to vote
0
Answered by
Ryukiyo 65
8 years ago

One of the most frequent mistakes made with an error such as this one is that the script fails to locate an object that hasn't been completely loaded into the game yet upon startup. Consider using the WaitForChild function to allow the script to wait until a certain object has been loaded properly.

Another mistake I found in the script that you may want to be aware of is contained within lines 34 - 38. You attempt to compare string values with mathematical operators, which will cause another error.

You can convert the strings to number values with the use of tonumber, or you can simply fix the issue by removing the secondary if statement since you are necessarily needing only one condition to be met for the script to continue running.

MINOR EDIT: You may also want to consider changing the name for "Name", as it may confuse the script with the object's actual name.

-- Login script

wait(0.1)

ap = require(game.Workspace.TrelloAPI)
BoardID = "IQtYgu2z"
ListID = ap:GetListID("Computer Logins",BoardID)

local db = false
local player = script.Parent.Parent.Parent.Parent.Parent
local userid = player.UserId
local placeid = game.PlaceId

script.Parent.MouseButton1Click:connect(function()
    if not db then
    db = true

    local Main = script.Parent.Parent
    local Rank = Main:WaitForChild("Rank").Text
    local Name = Main:WaitForChild("Name").Text -- [[ May want to change "Name" to a different name. ]]
    local Code = Main:WaitForChild("Code").Text 

    script.Parent.Text = "Please wait"

    CardID = ap:AddCard("Computer Login By: "..(player.Character.Name).." || ID: "..(userid),"**Rank:** "..Rank.."\n\n**Name:** "..(Name).."\n\n**Entered Code:** "..(Code).."",ListID)

if Code == "1497" then 
    Main.Visible = false
    script.Parent.Parent.Parent["Windows Frame"].Visible = true

else --[[ if Code's text value doesn't equal 1497 then ]]
    Code = "Incorrect code"
    end
end)

If you have any questions about the answer I provided, please message me back and I'll be happy to clear it up for you. Thanks.

Ad

Answer this question