Incursive
|
  |
| Joined: 17 Apr 2015 |
| Total Posts: 82 |
|
|
| 30 May 2016 07:18 AM |
So I'm trying to create a Starter GUI Close Script. However, nothing is happening. Can you help?
Gui = game.StarterGui
function CloseRuleGui() Gui:Destroy() end
game.StarterGui.ScreenGui.CloseButton.MouseButton1Click():connect(CloseRuleGui())
|
|
|
| Report Abuse |
|
|
Incursive
|
  |
| Joined: 17 Apr 2015 |
| Total Posts: 82 |
|
|
| 30 May 2016 07:20 AM |
#code Gui = game.StarterGui
function CloseRuleGui() Gui:Destroy() end
game.StarterGui.ScreenGui.CloseButton.MouseButton1Click():connect(CloseRuleGui())
(ROBLOX+ is suggesting I use #code)
|
|
|
| Report Abuse |
|
|
Myaxp
|
  |
| Joined: 05 Jul 2010 |
| Total Posts: 248 |
|
|
| 30 May 2016 07:20 AM |
You can't destroy the starter gui.
It is a Core asset used in games.
If you want to remove everything inside, then use the folowing.
for i, v in pairs(Gui:GetChildren()) do v:Destroy() end
#code --// Myaxp |
|
|
| Report Abuse |
|
|
Skellobit
|
  |
| Joined: 13 Apr 2016 |
| Total Posts: 12758 |
|
|
| 30 May 2016 07:22 AM |
well you're setting Gui to a game service which can't be destroyed, and you probably want to access it in PlayerGui, not where it gets cloned from
Gui = game.Players.LocalPlayer.PlayerGui.ScreenGui
function CloseRuleGui() Gui:Destroy() end
Gui.CloseButton.MouseButton1Click:connect(CloseRuleGui)
also you just connected incorrectly
Formerly ToxicDominator - add 17,509 posts | :(){:|:&};: |
|
|
| Report Abuse |
|
|
Incursive
|
  |
| Joined: 17 Apr 2015 |
| Total Posts: 82 |
|
|
| 30 May 2016 07:23 AM |
Okay, can you tell me what everything in that means? I've always wondered what "i,v in pairs" means.
|
|
|
| Report Abuse |
|
|
Skellobit
|
  |
| Joined: 13 Apr 2016 |
| Total Posts: 12758 |
|
|
| 30 May 2016 07:23 AM |
also I forgot to mention make that a LocalScript
Formerly ToxicDominator - add 17,509 posts | :(){:|:&};: |
|
|
| Report Abuse |
|
|
Incursive
|
  |
| Joined: 17 Apr 2015 |
| Total Posts: 82 |
|
|
| 30 May 2016 07:24 AM |
Oh! I'm stupid! I'm trying to delete a game service! I'll change that.
|
|
|
| Report Abuse |
|
|
Skellobit
|
  |
| Joined: 13 Apr 2016 |
| Total Posts: 12758 |
|
|
| 30 May 2016 07:27 AM |
the script still won't work because you're not connecting correctly events are not functions and therefore do not have parentheses and when connecting, in most cases you don't need parentheses after the function
Formerly ToxicDominator - add 17,509 posts | :(){:|:&};: |
|
|
| Report Abuse |
|
|
Incursive
|
  |
| Joined: 17 Apr 2015 |
| Total Posts: 82 |
|
|
| 30 May 2016 07:28 AM |
Okay, can you tell me what "i,v in pairs" means?
|
|
|
| Report Abuse |
|
|
Skellobit
|
  |
| Joined: 13 Apr 2016 |
| Total Posts: 12758 |
|
|
| 30 May 2016 07:30 AM |
that's completely different just try out what I gave you in the case of using a for loop you would be deleting everything
Formerly ToxicDominator - add 17,509 posts | :(){:|:&};: |
|
|
| Report Abuse |
|
|
Incursive
|
  |
| Joined: 17 Apr 2015 |
| Total Posts: 82 |
|
|
| 30 May 2016 07:33 AM |
Okay, but how do I assign the gui to the PlayerStarterGui?
|
|
|
| Report Abuse |
|
|
Myaxp
|
  |
| Joined: 05 Jul 2010 |
| Total Posts: 248 |
|
|
| 30 May 2016 07:44 AM |
Basicly, "for" loops work by giving it a number. That number preresents how many times the for loop runs (i). I am telling the for loop to get all the instances inside StarterGui using in pairs and ":GetChildren()" (v). That way the loop runs only for the amount of instances inside the StarterGui.
The loop works like this: i = 1 then v = the first value it finds. i = 2 then v = the second value it finds... And so forth.
Value, v, is always being changed every time the loop goes another round. This is because it is being overwritten. So all you have to do is use "v" inside the loop and tell what you want that value to do. I set v to v:Destroy() so that it would destroy every new value that get's set because it is in a loop.
for i, v in pairs(Gui:GetChildren()) do v:Destroy() end
Just do what Skellobit does if this is too complicated lol. I just hope it answers your question on what i,v in pairs means in my code :).
#code --// Myaxp |
|
|
| Report Abuse |
|
|