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

Help with Visible Gui?

When I touch a part the is located in script.Parent, the Frame tahts located in TouchedGui does not show up.

script.Parent.Touched(function()
	local Gui = game.StarterGui.TouchedGui.Frame
	if Gui.Visible == false then
	Gui.Visible = true
	print'True'
	else
	Gui.Visible = false
	print'False'
	

	end
end)

2 answers

✓ Accepted answer

The problem is that you're trying to get the Player's Gui from the StarterGui when the Player's Gui is inside the PlayerGui which is inside the Player. To get the Player from the Touched event we will need to use GetPlayerFromCharacter().

Debounce = false
script.Parent.Touched:connect(function(Hit)--The Function listen for the Touched Event.
   local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)--Gets the Player From the
	if not Debounce and Player then
	Debounce = true
	 Character.
    local Gui = Player.PlayerGui.TouchedGui.Frame--Variable for Quick access.
    Gui.Visible = not  Gui.Visible--If Visible is False it turns it true,If Visible is true it turns it false.
 	wait(2)
	Debounce = false
	end
end)

To fix your problem, you need to access the PlayerGui rather than the StarterGui. To get the player, we'll have to get the character from the part that touched it, then go from there. (Also you forgot to connect the function)

script.Parent.Touched:connect(function(Part)
	local Player = game.Players:GetPlayerFromCharacter(Part.Parent) --Function that gets the player from the character, which is that parts parent.
	if Player then --Makes sure Player exists
		local Gui = Player.PlayerGui.TouchedGui.Frame
		if Gui.Visible == false then
			Gui.Visible = true
			print'True'
		else
			Gui.Visible = false
			print'False'
		end
	end
end)

Ok, now your script should work. If you have any further problems/questions, please leave a comment below, and I'll see what I can do. Hope I helped :P

####-Dyler3

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