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
 

Re: Return

Previous Thread :: Next Thread 
Raphael7 is not online. Raphael7
Joined: 03 Dec 2008
Total Posts: 2479
16 Jun 2016 02:25 PM
function findParent(mdl)
print('>>',mdl)
if mdl.Parent ~= workspace then
findParent(mdl.Parent)
elseif mdl.Parent == workspace then
print('>>>',mdl)
return mdl
end
end

print(findParent(game.Workspace.Player1.Torso).Name)

It prints Player1, which is what I want, but it returns nil. Why does it return nil?
Report Abuse
Skellobit is not online. Skellobit
Joined: 13 Apr 2016
Total Posts: 12758
16 Jun 2016 02:28 PM
remove .Name, you're attempting to find the parent of a string

Formerly ToxicDominator - add 17,509 posts | :(){:|:&};:
Report Abuse
Raphael7 is not online. Raphael7
Joined: 03 Dec 2008
Total Posts: 2479
16 Jun 2016 02:31 PM
Yeah, it still doesn't work.
Report Abuse
Skellobit is not online. Skellobit
Joined: 13 Apr 2016
Total Posts: 12758
16 Jun 2016 02:35 PM
I just tested it and it works fine for me

Formerly ToxicDominator - add 17,509 posts | :(){:|:&};:
Report Abuse
Raphael7 is not online. Raphael7
Joined: 03 Dec 2008
Total Posts: 2479
16 Jun 2016 02:38 PM
function findParent(mdl)
print('>>',mdl)
if mdl.Parent ~= workspace then
findParent(mdl.Parent)
elseif mdl.Parent == workspace then
print('>>>',mdl)
return mdl
end
end

x = game.Workspace:FindFirstChild(findParent(game.Workspace.Model.Part)) print(x)

What does it return? I was hoping I could obtain the model or something.
Report Abuse
Skellobit is not online. Skellobit
Joined: 13 Apr 2016
Total Posts: 12758
16 Jun 2016 02:41 PM
it's supposed to print an ancestry tree of the specified object (except Workspace), correct?

Formerly ToxicDominator - add 17,509 posts | :(){:|:&};:
Report Abuse
Skellobit is not online. Skellobit
Joined: 13 Apr 2016
Total Posts: 12758
16 Jun 2016 02:44 PM
by the way you should be using:



function findParent(mdl)
print('>>',mdl)
if mdl.Parent ~= workspace then
findParent(mdl.Parent)
elseif mdl.Parent == workspace then
print('>>>',mdl)
return mdl
end
end

print(findParent(game.Workspace.Model.Part))



which printed this for me:

>> Part
>> Model
>>> Model

Formerly ToxicDominator - add 17,509 posts | :(){:|:&};:
Report Abuse
Raphael7 is not online. Raphael7
Joined: 03 Dec 2008
Total Posts: 2479
16 Jun 2016 02:54 PM
That's what it prints inside, but it doesn't return any value. If you take out print,

function findParent(mdl)
print('>>',mdl)
if mdl.Parent ~= workspace then
findParent(mdl.Parent)
elseif mdl.Parent == workspace then
print('>>>',mdl)
return mdl
end
end

findParent(game.Workspace.Model.Part)

It would still print out those values, but when you check to see what it returns, it doesn't print anything.

Report Abuse
Raphael7 is not online. Raphael7
Joined: 03 Dec 2008
Total Posts: 2479
16 Jun 2016 02:56 PM
Nvm, I fixed it.
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