generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Returning the Instance?

Previous Thread :: Next Thread 
Seizurezxzz is not online. Seizurezxzz
Joined: 12 Feb 2013
Total Posts: 1297
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
Seizurezxzz is not online. Seizurezxzz
Joined: 12 Feb 2013
Total Posts: 1297
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
Seizurezxzz is not online. Seizurezxzz
Joined: 12 Feb 2013
Total Posts: 1297
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
Seizurezxzz is not online. Seizurezxzz
Joined: 12 Feb 2013
Total Posts: 1297
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
Seizurezxzz is not online. Seizurezxzz
Joined: 12 Feb 2013
Total Posts: 1297
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image