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

GUI only opens once after closing. If i close the GUI, it doesn't open again. Anyone know why?

Asked by
iiii676 23
4 years ago
Edited 4 years ago

Here is my code (This Opens the GUI, Uses Normal Script)

script.Parent.MouseClick:Connect(function(Player)
    print(Player.Name)
    game.Players[Player.Name].PlayerGui.ScreenGui.Frame.Visible = true
end)

I use my close button: (Uses LocalScript)

script.Parent.MouseButton1Click:Connect(function()
    game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.Visible = false
end)

After I open the GUI and close it, If I try to open it again it just won't open, It still prints my name and doesn't show any errors.

Anybody know why?

2 answers

Log in to vote
0
Answered by 4 years ago

In your first script, MouseClick isn't a valid member of a GUI. You also can't have a player argument. GUIs are always supposed to work from LocalScripts because they run on the Client and never on the Server. Have your first script be a LocalScript and use .MouseButton1Click instead.

script.Parent.MouseButton1Click:Connect(function()
    print(game.Players.LocalPlayer.Name)
    game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.Visible = true
end)
0
Im using a ClickDetector so I cant use MouseButton1Click iiii676 23 — 4y
0
But i'll try with the LocalScript iiii676 23 — 4y
0
Oh if you’re using a ClickDetector, then you would check if the ClickDetector was clicked and not the GUI itself. So you would do ClickDetector.MouseClick. AntiWorldliness 868 — 4y
Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

I had a similar problem, you can't open and close the script on two types of scripts, you have to single it out to one type. Its because its still open on the server side of it but not locally.

Answer this question