|
| 23 Dec 2016 06:19 PM |
So I just posted if this was possible, and for my game I came up with this code, sorry if it is a bit long to read
But the thing is, the "Pos" it is searching for, is definitely there. x just always returns nil when it should have found the object I was searching for.
function FindLowest(Pos) print("Running") local x = nil local t = {} local TE = script.Parent.TeamEditor local O = TE.Offence:GetChildren() if O[Pos] then print("Running O") for i,v in next, O do print(v.Name, tonumber(O[Pos].PlayerOverall.Text)) table.insert(t,#t+1,tonumber(O[Pos].PlayerOverall.Text)) end local Lowest = math.min(t) for i,v in next, O do if tonumber(O[Pos].PlayerOverall.Text) == Lowest then print("Found!") x = v break end end end if x == nil then return false end return x end end |
|
|
| Report Abuse |
|
|
|
| 23 Dec 2016 06:25 PM |
Sorry to be unclear on some things. TE is defined with a Gui O is defined as a Frame within the Gui And Pos is being used to find a Frame within the "O" Frame |
|
|
| Report Abuse |
|
|
|
| 23 Dec 2016 06:31 PM |
| Fixed it, I had to replace the "[..]"s with FindFirstChild()'s for some reason and edit it from there... Weird. |
|
|
| Report Abuse |
|
|
|
| 23 Dec 2016 06:37 PM |
Wait lol... Still returns nil value...
if tonumber(O:FindFirstChild(Pos).PlayerOverall.Text) == Lowest then print("Found!") x = O:FindFirstChild(Pos) break end
It prints found but when I have this: local StarterFrame = FindLowest(script.Parent.ManageTeam.SelectedPlayer.PlayerPosition.Text) print(StarterFrame.Name)
--------------- It Errors with a nil value even there it prints "Found!"
|
|
|
| Report Abuse |
|
|
|
| 23 Dec 2016 06:42 PM |
Fixed it again....
if tonumber(O:FindFirstChild(Pos).PlayerOverall.Text) == Lowest then print("Found!") x = O:FindFirstChild(Pos) return x end
Sorry guys |
|
|
| Report Abuse |
|
|