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

Attempt to index string with 'Text'?

Asked by
CodeWon 181
2 years ago

I tried to change a gui text in a script and I got this error: Attempt to index string with 'Text'

Script:

local gui = script.BillboardGui:Clone()
gui.Parent = workspace:WaitForChild(player.Name):WaitForChild("Head")

gui.Name.Text = player.DisplayName.." (@"..player.Name..")"
0
gui:FindFirstChild("Name").Text or rename "Name" to something else greatneil80 2647 — 2y

1 answer

Log in to vote
1
Answered by 2 years ago

The problem is that you're trying to find the property "Text" on a GUI (when in fact it should be found on a textlabel) or the fact that you put the textlabel name as "Name" which is a property of all Objects in roblox studio. Try naming it something else or use :WaitForChild() / :FindFirstChild()

local gui = script.BillboardGui:Clone()
local TextLabel = gui:WaitForChild("TextLabel") -- or whatever you named the text label
gui.Parent = workspace:WaitForChild(player.Name):WaitForChild("Head")

TextLabel.Text = player.DisplayName.." (@"..player.Name..")"

This should work.

Ad

Answer this question