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
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).
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)