Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My gui won't appear and hide but why?

Asked by 4 years ago
Edited 4 years ago

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

0
Are there any errors? LikeToScript 108 — 4y
0
lets see Eric_pokemon 133 — 4y
0
there is Eric_pokemon 133 — 4y

3 answers

Log in to vote
2
Answered by
JesseSong 3916 Moderation Voter Community Moderator
4 years ago
Edited 3 years ago

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

Ad
Log in to vote
2
Answered by 4 years ago
Edited 4 years ago
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).

0
but it only hides the gui i want to show it when click Eric_pokemon 133 — 4y
0
and when it's showing and you click it then it hides Eric_pokemon 133 — 4y
Log in to vote
1
Answered by 4 years ago

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)

Answer this question