|
| 20 Jun 2015 10:02 PM |
It says "Syntax error: Expression must be a variable or a field" when I try to run this script:
function onButtonClicked() for i,v in pairs do (game.Players.LocalPlayer.PlayerGui.DefaultGUI:GetChildren()) if v.Name = "DoorOptions" then v:Destroy() end end end
script.Parent.MouseButton1Click:connect(onButtonClicked)
What's wrong?
u sicko! |
|
|
| Report Abuse |
|
|
DrSaint
|
  |
| Joined: 14 Oct 2009 |
| Total Posts: 18429 |
|
|
| 20 Jun 2015 10:05 PM |
| Try OnClicked instead of OnButtonClicked |
|
|
| Report Abuse |
|
|
|
| 20 Jun 2015 10:06 PM |
@DrSaint WRONG
The error is this:
if v.Name = "DoorOptions" then
It should be
if v.Name == "DoorOptions" then |
|
|
| Report Abuse |
|
|
|
| 20 Jun 2015 10:06 PM |
...That did literally nothing. I should mention that the error is on line 2.
u sicko! |
|
|
| Report Abuse |
|
|
|
| 20 Jun 2015 10:06 PM |
Anyway, thanks for pointing out that error for me.
u sicko! |
|
|
| Report Abuse |
|
|
DrSaint
|
  |
| Joined: 14 Oct 2009 |
| Total Posts: 18429 |
|
|
| 20 Jun 2015 10:07 PM |
@CLONE
AH EEH GAD DONT SCREAM AT ME I HAVE SENSITIVE EARS |
|
|
| Report Abuse |
|
|
DrSaint
|
  |
| Joined: 14 Oct 2009 |
| Total Posts: 18429 |
|
|
| 20 Jun 2015 10:08 PM |
@Klink
Always post the error line. Makes it much easier and faster to track down. Doesn't make me look like an idiot too. |
|
|
| Report Abuse |
|
|
|
| 20 Jun 2015 10:11 PM |
Anyway, what's wrong with my script? Am I using GetChildren() wrong?
u sicko! |
|
|
| Report Abuse |
|
|
|
| 20 Jun 2015 10:13 PM |
"do" goes at the end of the line
for i,v in pairs(game.Players.LocalPlayer.PlayerGui.DefaultGUI:GetChildren()) do
pairs is a function that accepts the table you want to loop over pairs(tab) |
|
|
| Report Abuse |
|
|
|
| 20 Jun 2015 10:13 PM |
Oh wait I missed that too. It should be:
function onButtonClicked() for _,v in pairs(game.Players.LocalPlayer.PlayerGui.DefaultGUI:GetChildren()) do if v.Name == "DoorOptions" then v:Destroy() end end end
script.Parent.MouseButton1Click:connect(onButtonClicked) |
|
|
| Report Abuse |
|
|
|
| 20 Jun 2015 10:14 PM |
Thanks, that helps a lot.
u sicko! |
|
|
| Report Abuse |
|
|
DrSaint
|
  |
| Joined: 14 Oct 2009 |
| Total Posts: 18429 |
|
|
| 20 Jun 2015 10:14 PM |
| Oh see I wasn't even close, I make myself look like an idiot lmao |
|
|
| Report Abuse |
|
|