|
| 22 Mar 2017 10:59 PM |
so previously in the past I've done things where say I want all textbuttons under "swag" to run the same command and i'll write something like
for _,v in pairs(game.StarterGui.swag:getChildren()) do v.MouseButton1Click:connect(function() print'yolo' end) end
and this would work fine, but I'm working on a chess engine now, and I want the person to be able to play. so what I've done is made a function that analyzes the 2 buttons you click (it records the first one), however the input saying unexpected symbol near ')' on my end) line. here's my script.
for _,v in pairs(script.Parent.Sur:GetChildren()) do v.MouseButton1Click:connect(function() if script.ChosenPiece.Value == 'NA' and v.Text ~= '' and getside(v) == 2 and script.Parent.WTM.Value == true then script.ChosePiece.Value = v.Name local opts = options(v) for _,c in pairs(opts) do local cl = script.Copy:Clone() cl.Parent = c end elseif script.ChosenPiece.Value ~= 'NA' and script.Parent.WTM.Value == true then local opts = options(script.Parent.Sur[script.ChosenPiece.Value]) local legal = false for _,c in pairs(opts) do if v == c then legal = true end end if legal == true then v.Text = script.Parent.Sur[script.ChosenPiece.Value].Text v.TextColor3 = script.Parent.Sur[script.ChosenPiece.Value].TextColor3 script.Parent.WTM.Value = false script.ChosePiece.Value = 'NA' for _,d in pairs(script.Parent.Sur:GetChildren()) do if d['Copy'] then d['Copy']:remove() end end moverandom() else print'this move is not legal' script.ChosenPiece.Value = 'NA' for _,d in pairs(script.Parent.Sur:GetChildren()) do if d['Copy'] then d['Copy']:remove() end end end end) -- output's saying the problem is on this line. end
I cannot find the issue |
|
|
| Report Abuse |
|
|
LaeMVP
|
  |
| Joined: 24 Jun 2013 |
| Total Posts: 4416 |
|
|
| 22 Mar 2017 11:00 PM |
| Keep printing till you find what breaks. |
|
|
| Report Abuse |
|
|
Dorandir
|
  |
| Joined: 06 Aug 2016 |
| Total Posts: 844 |
|
| |
|
|
| 22 Mar 2017 11:02 PM |
| the first line doesn't execute. |
|
|
| Report Abuse |
|
|
|
| 22 Mar 2017 11:02 PM |
dont do what lae said
for _,v in pairs(script.Parent.Sur:GetChildren()) do v.MouseButton1Click:connect(function() if script.ChosenPiece.Value == 'NA' and v.Text ~= '' and getside(v) == 2 and script.Parent.WTM.Value == true then script.ChosePiece.Value = v.Name local opts = options(v) for _,c in pairs(opts) do local cl = script.Copy:Clone() cl.Parent = c end elseif script.ChosenPiece.Value ~= 'NA' and script.Parent.WTM.Value == true then local opts = options(script.Parent.Sur[script.ChosenPiece.Value]) local legal = false for _,c in pairs(opts) do if v == c then legal = true end end if legal == true then v.Text = script.Parent.Sur[script.ChosenPiece.Value].Text v.TextColor3 = script.Parent.Sur[script.ChosenPiece.Value].TextColor3 script.Parent.WTM.Value = false script.ChosePiece.Value = 'NA' for _,d in pairs(script.Parent.Sur:GetChildren()) do if d['Copy'] then d['Copy']:remove() end end moverandom() else print'this move is not legal' script.ChosenPiece.Value = 'NA' for _,d in pairs(script.Parent.Sur:GetChildren()) do if d['Copy'] then d['Copy']:remove() end end end end end) end
|
|
|
| Report Abuse |
|
|
LaeMVP
|
  |
| Joined: 24 Jun 2013 |
| Total Posts: 4416 |
|
|
| 22 Mar 2017 11:04 PM |
| @iJacob Printing till you find an error works 99% of the time, so why not do it? |
|
|
| Report Abuse |
|
|
| |
|
|
| 22 Mar 2017 11:05 PM |
because with the error that was given it wouldnt have even helped, like he said the error printed right away.
|
|
|
| Report Abuse |
|
|
LaeMVP
|
  |
| Joined: 24 Jun 2013 |
| Total Posts: 4416 |
|
|
| 22 Mar 2017 11:06 PM |
| ah then we have hit the 1% |
|
|
| Report Abuse |
|
|
| |
|
|
| 22 Mar 2017 11:08 PM |
it does help when your not getting any underlines though.
|
|
|
| Report Abuse |
|
|