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

My gui won't appear and hide but why?

So I want to make a gui that if you click a button and the gui is showing the gui will hide or when the gui is hidden and if the person clicks the button it'll show but this script is not working .

Script

script.Parnet.MouseButton1Click:Connect(function()
	script.Parent.Parent:WaitForChild("InventoryFrame").Visible = not script.Parent.Parent:WaitForChild("InventoryFrame").Visible
end)

The error is

Parnet is not a valid member of LocalScript

3 comments

0

Are there any errors?

0

lets see

0

there is

3 answers

✓ Accepted answer

This code is an edit of Player1_Joined's code!

Basically, if you want it to do the opposite then use a not function.

script.Parent.MouseButton1Click:Connect(function() --Make sure to check the spelling of your code, you spelled "Parent" "Parnet"
    script.Parent.Parent:WaitForChild("InventoryFrame").Visible = not script.Parent.Parent:WaitForChild("InventoryFrame").Visible  --You put not instead of false
--script.Parent.Parent:WaitForChild("InventoryFrame").Visible I commented this out cause I wasn't sure what you wanted to do with this part
end)

Re-edited on 2/Feb/2021 - Fixed grammatical errors

script.Parent.MouseButton1Click:Connect(function() --Make sure to check the spelling of your code, you spelled "Parent" "Parnet"
    script.Parent.Parent:WaitForChild("InventoryFrame").Visible = false --You put not instead of false
--script.Parent.Parent:WaitForChild("InventoryFrame").Visible I commented this out cause I wasn't sure what you wanted to do with this part
end)

This should probably work, remember to check your code spelling (not trying to be rude).

2 comments

0

but it only hides the gui i want to show it when click

0

and when it's showing and you click it then it hides

I've had the exact same problem, The reason is because you need to make it visible in the players gui This is my script where if you touch the block the gui pops up Local script

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
		if plr then
			if not plr.PlayerGui:FindFirstChild("GUIClonedfromtouchblock") then
				local clonedgui = script.Parent:FindFirstChildOfClass("ScreenGui"):Clone()
				clonedgui.Name = "GUIClonedfromtouchblock"
				clonedgui.Parent = plr.PlayerGui
				wait(0)
				script.Parent.TouchEnded:Connect(function(hit2)
					if hit == hit2 then
						game.Debris:AddItem(clonedgui,0)
					end
				end)
			end
		end
	end
end)

or do this it might not work Use Server/normal script

local player = game.Players.LocalPlayer
script.Parnet.MouseButton1Click:Connect(function()
    script.Parent.Parent:WaitForChild("InventoryFrame").Visible = true
	player.PlayerGui:WaitForChild("InventoryFrame").Visible = true 
	
end)

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