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?
