So, here's the hierarchy for the ScreenGui.
And the only thing that's bugging the code is one of the variables, but they all seem to logically be assigned correctly. Help?
01 | local player = game.Players.LocalPlayer |
02 | local mouse = player:GetMouse() |
03 | local gui = player:WaitForChild( "PlayerGui" ).ScreenGui.Frame.TextLabel |
04 | local pinetree = game.Workspace.PineTree |
05 | local chair = game.Workspace.Chair |
06 | local chairframe = script.Parent.Chair |
07 |
08 | -- This should work, tbh. |
09 | mouse.Move:connect( function () |
10 | local target = mouse.Target |
11 | if target.Parent:IsA( "Model" ) then |
12 | if target.Parent = = pinetree then |
13 | gui.Text = "Pine tree" |
14 | gui.Visible = true |
15 | gui.Position = UDim 2. new( 0 ,mouse.X, 0 ,mouse.Y) |
The reason that it says that Frame
is not a valid member is because you need to use the method :findFirstChild
or :WaitForChild
for the frame like when you set the variable gui change it to something like...
1 | local gui = player:WaitForChild( "PlayerGui" ):WaitForChild( "ScreenGui" ):WaitForChild( "Frame" ):WaitForChild( "TextLabel" ) |
I'm think that is the problem because the code makes the computer think you're addressing its property.
Thank you for reading this answer and I hope I helped.
~~ KingLoneCat