Hi
I have a text label which is on a part. I would like the text label to change when a player runs into the part. I am trying to do this through a script which is a child to the part and which uses the ontouched function. However I can't find the right way to refer to the label. When I run the below code I get a message saying "SurfaceGui is not a valid part of MeshPart".
I've tried to paste a screenshot of the game layout but no luck. So I've described it using text
- Workspace is parent to Part
- Part is parent to a script (which is below)
- Part is also parent to SurfaceGui
- SurfaceGui is parent to Textlabel.
Thank you
Chris
************* Code starts *****************************
function onTouched(part)
local var = part.SurfaceGui.Frame.TextLabel
-- code to change the label will come here
end
script.Parent.Touched:connect(onTouched)
************* Code Ends *****************************
Thanks in advance for your help
Chris

1 comment
put your code in a code block next time