Why is this script giving an error?

I tried this script but it is printing the error:
TextLabel is not a valid member of Part “Workspace.Dummy.Text”

function onTouch (Touch)
	script.Parent.Parent.Text.SurfaceGui.TextLabel.Text = ("Test1")
	wait(3)
	script.Parent.Parent.Text.TextLabel.Text = (" Test2")
end
script.Parent.Touched:Connect(onTouch)

Also Text is a part.

The first thing i’d say is that strings dont need parenthesis, did you try assigning the string without them?

you forgot .SurfaceGui, i think thats the problem

function onTouch (Touch)
	script.Parent.Parent.Text.SurfaceGui.TextLabel.Text = ("Test1")
	wait(3)
	script.Parent.Parent.Text.SurfaceGui.TextLabel.Text = (" Test2")
end
script.Parent.Touched:Connect(onTouch)
1 Like

I’ll try right now…

when I do this the text just stays as test2 not even when I touch the part and when I touch it nothing happens

Can you show a screenshot of your error?

can you show a screenshot where the textlabel is located?

All it says is textlabel is not a valid member or part “Workspace.Dummy.Text”

The textlabel is located inside of SurfaceGui and SurfaceGui is inside Text which is a part inside Dummy (Rig)
Got it fixed!

You are trying to refer to the instance ‘TextLabel’ inside of the object ‘Workspace.Dummy.Text’ and that object you want to refer to does not exist, which is the cause of the error. If you named the object, make sure you have the right name or the right location of the TextLabel your refering to.