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

PlayerGui is not a valid member of meshpart?

This is my script and i've tried looking this error up but there's no posts about it? I'm very confused

script.Parent.Touched:Connect(function(player)
	player.PlayerGui.Info.TextLabel.Text = "find a way to break the wall."
end)

1 answer

When something is touched, it returns the part that touched it, not the player who touched it. To find the player who touched it, I would recommend checking whether the part touched is a limb of a player and then use that to find the player instance.

Here's your edited code:

script.Parent.Touched:Connect(function(hit)
	if hit.Parent and game:GetService("Players"):FindFirstChild(hit.Parent.Name) then
		local player = game:GetService("Players"):FindFirstChild(hit.Parent.Name)
		player.PlayerGui.Info.TextLabel.Text = "find a way to break the wall."
	end
end)

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