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

What Is Wrong With My Piece Of Code?

I'm trying to get a GUI placed in the toucher of a seat when they sit down, however it's turned out rather crooked.

GUI = script.Parent.GOLIATH

script.Parent.Touched:connect(function (hit)
	wait(0.5)
	if not script.Parent:FindFirstChild("SeatWeld") then return end
		if not game.Players:FindFirstChild(hit.Parent.Name).PlayerGui.GOLIATH then
			local NewGUI = GUI:Clone()
			NewGUI.Parent = game.Players:FindFirstChild(hit.Parent.Name).PlayerGui
	end
end)

That's the code, and it's throwing the error: GOLIATH is not a valid member of PlayerGui Script 'Workspace.Goliath Prototype, dawg.Part.Script', Line 6 Stack End

The objective of the script is to check if the player has the GUI, and if not, place the GUI on their screen. When they stop touching the seat, the GUI disappears.

1 answer

✓ Accepted answer

Try this if game.Players:FindFirstChild(hit.Parent.Name).PlayerGui.GOLIATH ~= nil then

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