|
| 26 Sep 2016 03:37 PM |
I'm trying to find the index in a folder where it's located in ServerStorage. A random index is chosen in the table, then added in the table 'receiveAssetsD', and initially trying to locate it in the folder to destroy it. How do I fix this error?
local StorageServer = game:GetService('ServerStorage') local DangerImg = StorageServer.GameCore.TileImages.Danger:GetChildren() local receiveAssetsD = {}
local Sorting = function() for i = 1,5 do table.insert(receiveAssetsD, DangerImg[math.random(#DangerImg)]) local hide = StorageServer.GameCore.TileImages.Danger:FindFirstChild(DangerImg[math.random(#DangerImg)]) hide:Destroy() wait(.1) end applyAssetToButton() end
button.MouseButton1Down:connect(Sorting)
|
|
|
| Report Abuse |
|
|
LockFocus
|
  |
| Joined: 31 Aug 2013 |
| Total Posts: 1044 |
|
|
| 26 Sep 2016 03:38 PM |
| It'd help if you posted the error. |
|
|
| Report Abuse |
|
|
|
| 26 Sep 2016 03:39 PM |
04:31:45.558 - Players.Player1.PlayerGui.MenuUI.CoreGame.StartUP:21: attempt to index local 'hide' (a nil value)
|
|
|
| Report Abuse |
|
|
LockFocus
|
  |
| Joined: 31 Aug 2013 |
| Total Posts: 1044 |
|
|
| 26 Sep 2016 03:42 PM |
| try removing the FindFirstChild, it's an error I get sometimes. |
|
|
| Report Abuse |
|
|
LockFocus
|
  |
| Joined: 31 Aug 2013 |
| Total Posts: 1044 |
|
|
| 26 Sep 2016 03:43 PM |
local StorageServer = game:GetService('ServerStorage') local DangerImg = StorageServer.GameCore.TileImages.Danger:GetChildren() local receiveAssetsD = {}
local Sorting = function() for i = 1,5 do table.insert(receiveAssetsD, DangerImg[math.random(#DangerImg)]) local hide = StorageServer.GameCore.TileImages.Danger[DangerImg[math.random(#DangerImg)])] hide:Destroy() wait(.1) end applyAssetToButton() end
button.MouseButton1Down:connect(Sorting)
|
|
|
| Report Abuse |
|
|
|
| 26 Sep 2016 03:45 PM |
But what's another way in locating the index? Or say locating the value that's in the folder, but has the same name as the index.
|
|
|
| Report Abuse |
|
|
|
| 26 Sep 2016 03:45 PM |
I'll try that right now on what you've posted.
|
|
|
| Report Abuse |
|
|
|
| 26 Sep 2016 03:47 PM |
It kind of posted this,
04:47:40.496 - Players.Player1.PlayerGui.MenuUI.CoreGame.StartUP:20: bad argument #2 to '?' (string expected, got Object)
|
|
|
| Report Abuse |
|
|
|
| 26 Sep 2016 03:50 PM |
I'm trying to think of other solutions on how to do it, just isn't coming in mind. :/
|
|
|
| Report Abuse |
|
|
LockFocus
|
  |
| Joined: 31 Aug 2013 |
| Total Posts: 1044 |
|
|
| 26 Sep 2016 03:50 PM |
whoops
local StorageServer = game:GetService('ServerStorage') local DangerImg = StorageServer.GameCore.TileImages.Danger:GetChildren() local receiveAssetsD = {}
local Sorting = function() for i = 1,5 do table.insert(receiveAssetsD, DangerImg[math.random(#DangerImg)]) local hide = StorageServer.GameCore.TileImages.Danger[DangerImg[math.random(#DangerImg)]).Name] hide:Destroy() wait(.1) end applyAssetToButton() end
button.MouseButton1Down:connect(Sorting) |
|
|
| Report Abuse |
|
|
|
| 26 Sep 2016 03:53 PM |
Whoa it worked, but threw a error because it didn't find the object in the folder xD, but still worked :o. I'm going to rewrite my code again, but will include on the information you've posted. Thank you LockFocus, it was a pleasure of you helping me. :)
|
|
|
| Report Abuse |
|
|
LockFocus
|
  |
| Joined: 31 Aug 2013 |
| Total Posts: 1044 |
|
| |
|
iIikeyou
|
  |
| Joined: 07 Mar 2012 |
| Total Posts: 1659 |
|
|
| 26 Sep 2016 04:17 PM |
you call math.random when adding the danger image to the table, and then again when actually destroying it it selects 2 different ones, i'd imagine thats the issue
local StorageServer = game:GetService('ServerStorage') local DangerImg = StorageServer.GameCore.TileImages.Danger:GetChildren() local receiveAssetsD = {}
local Sorting = function() for i = 1,5 do local img=DangerImg[math.random(#DangerImg)] table.insert(receiveAssetsD, img) img:Destroy() wait(.1) end applyAssetToButton() end
button.MouseButton1Down:connect(Sorting)
|
|
|
| Report Abuse |
|
|
|
| 26 Sep 2016 04:18 PM |
Yeah, I actually noticed that xD.
|
|
|
| Report Abuse |
|
|
|
| 26 Sep 2016 04:18 PM |
I was like 'what the heck is wrong with me' o.O But thank you for still telling me :P
|
|
|
| Report Abuse |
|
|