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

Why does my localscript keep returning error: attempt to index string with 'Text'?

I am working on an order system for a restaurant, and want to be able to record the username of the person ordering the food. So i created this localscript

script.Parent.Activated:Connect(function()
	--get clone
	local clone = game.StarterGui.Clonerdon.Order:Clone() clone.Parent = game.Workspace["Order taker"].Screen.SurfaceGui.ScrollingFrame
	--add username
	local username = script.Parent.Parent.TextBox.Text
	clone.Name.Text = username
end)

The localscript is in a textbutton in a frame in a screenGui. The clone's children are: Name (textlabel) Order (textlabel) Done (textbutton) script.Parent is a textbutton, and script.Parent.Parent.TextBox is a textbox.

Everytime i click one this button after entering a random word or username, it returns this error: TextButton.LocalScript:6: attempt to index string with 'Text' Script 'Players.Sergeant_Ranger.PlayerGui.Register.Frame.Ordersubmission.TextButton.LocalScript', Line 6

I have absolutely no idea why this is happening, but I imagine it might be an error stemming from how Roblox gets text from textlabels and textboxes.

Any help would be appreciated.

1 answer

✓ Accepted answer

Because the 'Name' is also a property in the 'clone.' Consider changing the name of the 'Name' TextBox to something like 'CloneName'

1 comment

0

ok thanks.

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