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

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

Asked by 4 years ago

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

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

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

0
ok thanks. sergeant_ranger 184 — 4y
Ad

Answer this question