Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Frame is not a valid member of ScreenGui?

So, here's the hierarchy for the ScreenGui.

  • ScreenGui
    • Interaction (localscript; code is situated here)
    • Frame
      • TextLabel
    • Chair
      • No
      • Yes

And the only thing that's bugging the code is one of the variables, but they all seem to logically be assigned correctly. Help?

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local gui = player:WaitForChild("PlayerGui").ScreenGui.Frame.TextLabel
local pinetree = game.Workspace.PineTree
local chair = game.Workspace.Chair
local chairframe = script.Parent.Chair

-- This should work, tbh.
mouse.Move:connect(function()
	local target = mouse.Target
	if target.Parent:IsA("Model") then
		if target.Parent == pinetree then
			gui.Text = "Pine tree"
			gui.Visible = true
			gui.Position = UDim2.new(0,mouse.X,0,mouse.Y)
		elseif target.Parent == chair then
			gui.Text = "Chair"
			gui.Visible = true
			gui.Position = UDim2.new(0,mouse.X,0,mouse.Y)
		else
			gui.Visible = false
		end
	end
end)

1 answer

✓ Accepted answer

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...

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

2 comments

0

Thank you! It worked.

0

Awesome!

This discussion is preserved as it was. New answers, comments, and votes are closed.