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

How would i disable this gui after it is clicked?

Asked by 10 years ago

I was wondering how to make a gui dissapear after it's clicked and when the character respawns it would reapear. Here is my script just to see if you coulda find something wrong. I tried game.StarterGui.Swordsmangiver.Disabled but it did not not work. if you could help me that would be greatly appreciated.

01-- creating a screen gui
02local screenGui = Instance.new("ScreenGui")
03screenGui.Parent = script.Parent
04 
05--make a text button
06local textButton = Instance.new ("TextButton")
07textButton.Parent = screenGui
08textButton.Position = UDim2.new(0,50,0,150)
09textButton.Size = UDim2.new(0,140,0,60)
10textButton.TextColor3 = BrickColor.White().Color
11textButton.Style = 3
12textButton.Text = "Swordsman"
13 
14--Bind function to button click
15textButton.MouseButton1Down:connect(function()
View all 25 lines...

Things to consider: This is a localscript inside the StarterGui. The script works and everything but i don't know how to disable after click and renable after death.

0
Turn off the visibility, it'll reactivate automatically if it's in startergui. Goulstem 8144 — 10y

1 answer

Log in to vote
2
Answered by 10 years ago

Assuming you want it do disable after clicking the textButton:

01-- creating a screen gui
02local screenGui = Instance.new("ScreenGui")
03screenGui.Parent = script.Parent
04 
05--make a text button
06local textButton = Instance.new ("TextButton")
07textButton.Parent = screenGui
08textButton.Position = UDim2.new(0,50,0,150)
09textButton.Size = UDim2.new(0,140,0,60)
10textButton.TextColor3 = BrickColor.White().Color
11textButton.Style = 3
12textButton.Text = "Swordsman"
13 
14--Bind function to button click
15textButton.MouseButton1Down:connect(function()
View all 28 lines...

Let me explain this. When the player spawns, the things from StarterGui clone into his PlayerGui. When I destroy the screenGui, I only destroy it from the PlayerGui, not the StarterGui (Where it gets cloned from). This means that when the player spawns again, the Gui can be used like normal.

0
Ok You've helped me see how this works now so ive named all my gui's now. lets say this one is screenGui1. How would i also destroy screenGui2,screenGui3,and screenGui4 all in this same script? gigabite176 20 — 10y
0
You can just simply do: screenGui1:Destroy() screenGui2:Destroy() screenGui3:Destroy() screenGui4:Destroy() .. Vlatkovski 320 — 10y
Ad

Answer this question