Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Textbox and string value error?

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

2 comments

0

Can you include more of the script? And also provide the line number, etc., for the error?

0

the rest of the script isn't related to that and the error is at line 6

1 answer

✓ Accepted answer

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.

2 comments

0

yeah makes perfect sence XD thanks it worked!

0

Also, you may want to move away from using Lighting as storage; Roblox has ReplicatedStorage and ServerStorage for that purpose.

This discussion is preserved as it was. New answers, comments, and votes are closed.