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

Textbox and string value error?

Asked by
Paldi 109
7 years ago

im trying to make a textbox that when a player type in something then click a button, it will take the text from the textbox and put it into a stringvalue but i get this error : bad argument #3 to 'Value' (string expected, got nil)

local player = game.Players.LocalPlayer
local name = game.Lighting.Players:FindFirstChild(player.Name).CivilName
function Done()
    player.Backpack.Camera:Destroy()
    local named = script.Parent.Name.Text
    name.Value = named
0
Can you include more of the script? And also provide the line number, etc., for the error? BlueTaslem 18071 — 7y
0
the rest of the script isn't related to that and the error is at line 6 Paldi 109 — 7y

1 answer

Log in to vote
1
Answered by
Pyrondon 2089 Game Jam Winner Moderation Voter Community Moderator
7 years ago

On line 5, you attempt to index script.Parent.Name. I assume you're trying to get a child of script.Parent with the name "Name", but Lua assumes you mean the Name property of script.Parent. You then attempt to index Name, which would just be a string in this case. You can remedy this using FindFirstChild:

local player = game.Players.LocalPlayer
local name = game.Lighting.Players:FindFirstChild(player.Name).CivilName
function Done()
    player.Backpack.Camera:Destroy()
    local named = script.Parent:FindFirstChild('Name').Text
    name.Value = named
end;

Hope this helped.

0
yeah makes perfect sence XD thanks it worked! Paldi 109 — 7y
0
Also, you may want to move away from using Lighting as storage; Roblox has ReplicatedStorage and ServerStorage for that purpose. Pyrondon 2089 — 7y
Ad

Answer this question