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

My shop GUI is not opening/closing properly in game?

Asked by
trecept 367 Moderation Voter
6 years ago
game.Workspace["shop"]:WaitForChild("brick").Touched:connect(function(player)
    if player.Parent:FindFirstChild("Humanoid") then
        local playername = game:GetService("Players"):FindFirstChild(player.Parent.Name)
        if playername.PlayerGui:WaitForChild("shop").Frame.Visible == false then
            playername.PlayerGui:WaitForChild("shop").Frame.Visible = true
        end
    end
end)

This is my script that "opens" (turns frame visible and not visible) a gui in the player's playergui when they touch a part called brick. It works in studio but when I test ingame there's an error: attempt to index a nil value on line 4 (when it checks whether the gui is visible or not) How do I fix this?

Answer this question