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

Is it possible to reset a GUI without killing the player?

Asked by 10 years ago

I have A GUI that is used to remove another GUI off the screen (because from time to time the other GUI gets locked up and is unresponsive).

This "GUI remover" works but if it could be re-scripted to just reset the unresponsive GUI, similarly to when a player rests, that would be a better solution.

Here is a copy of the script.

 local Gui = game.Players.LocalPlayer.PlayerGui:FindFirstChild("NewGame")

script.Parent.MouseButton1Click:connect(function(mouse)
Gui:Destroy()
end)

OK thanks to some help this is what I have so far.

I put the GUI "NewGame" in lighting and the "destroy/clone" GUI is in the StarterGui.

This is how it's scripted.

local Gui = game.Players.LocalPlayer.PlayerGui:FindFirstChild("NewGame")

script.Parent.MouseButton1Click:connect(function()
Gui:Destroy()
wait(1)
Game.Lighting.NewGame:Clone().Parent = game.Players.LocalPlayer.PlayerGui
end)

So close but not quite there! Now when I click the GUI remover/reseter, it clears the "NewGame" GUI and waits 1 sec and the cloned GUI returns. However, clicking it a second time I found the "NewGame" was not destroyed just cloned. This can be spam clicked cloning endless "NewGame" GUIs...

Why does it not destroy the “NewGame” GUI after the first click?

0
I don't know if you got the new message or not, but i updated the code, does it work now? lomo0987 250 — 10y

3 answers

Log in to vote
1
Answered by
lomo0987 250 Moderation Voter
10 years ago

I believe you can use :Clone()

You would set what you would want it to be reset as located in lighting for example.. You would then clone it like..

GUI = game.Lighting.(GUI)

Then you would want to destroy the GUI located within the player and clone the GUI into the starter gui of the player

I believe this would work. But I don't know exactly because i've never done anything like this before.

Edit: (Below)

repeat wait() until game.Players.LocalPlayer -- This will repeat until the player joins.
print("Player has Joined")
player = game.Players.LocalPlayer
print("Created Player")
newgui  = game.Lighting:FindFirstChild("NewGame"):Clone()
print("Created New GUI")
gui = player.StarterGUI:FindFirstChild("...") -- Fill that in with what you want to remove
print("Found GUI")

script.Parent.MouseButton1Click:connect(function()
print("GUI clicked")
gui:Destroy()
print("Gui Destroyed")
wait(1)
newgui.Parent = player.StarterGUI
print("Gui remade")) -- I also for got the ")" for the one before the function.. So that most likely broke it.. Sorry that I missed something like that.

This should work now. As long as you fill in line 3 with the correct name of the GUI

0
OK I'll give it a go. RobloxBossk 20 — 10y
0
Thank you lomo0987, I put a copy of the GUI "NewGame" in lighting, and pasted this in to the GUT remover/reseter. local Gui = game.Players.LocalPlayer.PlayerGui:FindFirstChild("NewGame") script.Parent.MouseButton1Click:connect(function() Gui:Destroy() wait(1) Game.Lighting.NewGame:Clone().Parent = LocalPlayer.PlayerGui end) However, when I uploaded my game, the GUI "NewGame" was destroyed but RobloxBossk 20 — 10y
0
There must have an error in it somewhere. It had the red squiggly lines and when I tested it, it didn’t do anything. RobloxBossk 20 — 10y
0
what was the output? lomo0987 250 — 10y
View all comments (2 more)
0
I can't get it to give me an output on it. RobloxBossk 20 — 10y
0
I added a few more things to it to improve the button. Now it should work? lomo0987 250 — 10y
Ad
Log in to vote
0
Answered by 10 years ago

I think there is but I'm not sure what kind of code you would need for it to work.

Log in to vote
0
Answered by 10 years ago

Thank you lomo0987, I put a copy of the GUI "NewGame" in lighting, and pasted this in to the GUI remover/reseter.

local Gui = game.Players.LocalPlayer.PlayerGui:FindFirstChild("NewGame")

script.Parent.MouseButton1Click:connect(function()
Gui:Destroy()
wait(1)
Game.Lighting.NewGame:Clone().Parent = LocalPlayer.PlayerGui
end)

However, when I uploaded my game, the GUI "NewGame" was destroyed but not replaced by a clone in my PlayerGui. Anyone see the problem?

0
Hey, i made the script for you. I just edited my old answer. It should work fine for you. lomo0987 250 — 10y

Answer this question