|
| 08 Apr 2016 02:11 PM |
Perhaps Flux was right, I am an idiot :P So the following code is meant to loop through a folder's children (Which is more folders). Here is the hierarchy: https://gyazo.com/95131e6e432b2ee140c968f8c49ea943
Here is what it, frustratingly, prints: yeeep GamepassData WalkspeedAdd5 is not a valid member of Folder
No idea why
local AdditionalWalkspeed = Library.FindGamepassBonus(GamepassData.Walkspeed, Player)
function Library.FindGamepassBonus(Location, Player) local add = 0 print'yeeeep' print(Location.Parent.Name) print(Location["WalkspeedAdd5"].Addition.Value) for x,y in pairs(Location:GetChildren())do print'sfdsdsdsdsfdsfdsfds' print(y.Name) print(y.Addition.Value) print(add) if Service:PlayerOwnsAsset(Player, y.ProductId.Value) then if y.Addition.Value > add then add = y.Addition.Value end end end print'2' |
|
|
| Report Abuse |
|
|
LuaLlama
|
  |
| Joined: 25 Jan 2014 |
| Total Posts: 1123 |
|
|
| 08 Apr 2016 02:16 PM |
| Location:WaitForChild("WalkspeedAdd5") |
|
|
| Report Abuse |
|
|
| |
|
LuaLlama
|
  |
| Joined: 25 Jan 2014 |
| Total Posts: 1123 |
|
| |
|
|
| 08 Apr 2016 02:35 PM |
Location is Walkspeed, not WalkspeedAdd5
for x,y in pairs(Location["WalkspeedAdd5"]:GetChildren())do
Not sure if it will work, but this is my go at it.
|
|
|
| Report Abuse |
|
|
|
| 08 Apr 2016 03:59 PM |
| Location is Walkspeed, WalkspeedAdd5 is a child. [""] is how you get a child when it doesn't have a normal variable name, although the [""] is left over from a different name, so I could probably get rid of that |
|
|
| Report Abuse |
|
|
| |
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 08 Apr 2016 05:46 PM |
"Perhaps Flux was right, I am an idiot"
You just realized this? Lol this thread is laughable.
|
|
|
| Report Abuse |
|
|
|
| 08 Apr 2016 05:57 PM |
| Just to rub it in a bit more, I don't suppose you could provide the solution. Because, this is really irritating me. It should be easy! |
|
|
| Report Abuse |
|
|
| |
|
Casualist
|
  |
| Joined: 26 Jun 2014 |
| Total Posts: 4443 |
|
|
| 08 Apr 2016 06:58 PM |
| IQ of 142, you got this m8. |
|
|
| Report Abuse |
|
|
|
| 09 Apr 2016 06:38 AM |
| Oh, ffs. This is ridiculous. I must of put location as the wrong place, but I can't see what it should be instead |
|
|
| Report Abuse |
|
|
Cuyler
|
  |
| Joined: 27 Feb 2006 |
| Total Posts: 3784 |
|
|
| 09 Apr 2016 06:49 AM |
Your code worked fine for me when I had it like this:
local Library = {} local Player = nil local GamepassData = game:GetService('ReplicatedStorage'):WaitForChild('GamepassData') local Service = game:GetService('MarketplaceService')
function Library.FindGamepassBonus(Location, Player) local add = 0 print'yeeeep' print(Location.Parent.Name) print(Location["WalkspeedAdd5"].Addition.Value) for x,y in pairs(Location:GetChildren())do print'sfdsdsdsdsfdsfdsfds' print(y.Name) print(y.Addition.Value) print(add) if Service:PlayerOwnsAsset(Player, y.ProductId.Value) then if y.Addition.Value > add then add = y.Addition.Value end end end print'2' end
local AdditionalWalkspeed = Library.FindGamepassBonus(GamepassData.Walkspeed, Player)
With the hierarchy being this: https://gyazo.com/a021e23575810f67335de2a4963b7e51
Output: https://gyazo.com/8e5af974a575681955cff89ac4d2882d
|
|
|
| Report Abuse |
|
|