The title may have been confusing, so I'm sorry, but I'm trying to make a dialog gui from scratch (I'm new to scripting, I'm trying to make things myself so I can understand how they work) and you have to click a player to enable the gui. It works once, I can click the player, it enables the gui, I click the close button, and it closes. When I click the player after that, It doesn't get enabled. I'm not sure what to do about it.
script.Parent.MouseClick:Connect(function(player)
player:WaitForChild("PlayerGui").dialog.Enabled = true
player.Character.Humanoid.WalkSpeed = 0
player.Character.Humanoid.JumpPower = 0
print("open");
end)
^^^ The code to enable the gui
vvv The code used to close the gui
script.parent.op3.MouseButton1Click:connect(function(player)
game.Players.LocalPlayer.PlayerGui.dialog.Enabled = false
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 16
game.Players.LocalPlayer.Character.Humanoid.JumpPower = 50
print("close");
end)
The "print("open");" still prints after the first time closing even though it doesn't get enabled.
Thank you in advance to anyone who responds.

3 comments
Can you please add a print(player:WaitForChild("PlayerGui").dialog.Enabled) in both and tell us the output please?
Can you please add a print(player:WaitForChild("PlayerGui").dialog.Enabled) in both and tell us the output please?
Sorry for the late response, but when I click it the first time it says "true", and when I click to close on the gui it says "Players.LiquidGaming.PlayerGui.dialog.all.close:7: attempt to index local 'player' (a nil value)" The script to open it is a normal script, the script to close it is a local script.