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

What does "PlayerGui is not a valid member of Part" mean?

I made a script to show a GUI when touched.

function loadscreen(hit)
	if not hit.PlayerGui:FindFirstChild("Gui") then
		local gui = script.Gui:clone()
		gui.Parent = hit.PlayerGui
	end
end


script.Parent.Touched:connect(loadscreen)

However, the outputs shows the message seen in the title and it fails to work. Help?

1 answer

✓ Accepted answer

The error message isn't lying! :P

When whatever is being connected to the Touched event is touched, the variable 'hit' will (almost?) always be a Part. Parts don't usually contain PlayerGuis, Player objects do. Somehow you need to find the Player object from that 'hit' part. Good luck!

2 comments

0

Have your first rep. :P

0

Why, thank you! :D

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