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 » Roblox » All Things ROBLOX
Home Search
 

Found an rbx.lua bug

Previous Thread :: Next Thread 
ForeverDev is not online. ForeverDev
Joined: 04 Oct 2008
Total Posts: 13300
18 Mar 2015 01:37 PM
Let's say you have a local script that needs to wait for an object to load. It is first nature to use :WaitForChild(instance_name)

Let's also assume the object is going to be created from the server and put into the LocalPlayer. Knowing all of this, we can write:

local object = game.Players.LocalPlayer:WaitForChild("SomeInstanceName")

However, I've found that if you call WaitForChild from the CLIENT, and insert the object from the SERVER, :WaitForChild will not recognize the child, and will yield infinitely.

The only way you can fix this, I've found, is:

local object;
repeat wait() object = game.Players.LocalPlayer:FindFirstChild("SomeInstanceName") until object

The solution is pretty inefficient and ugly. ROBLOX, could you try to fix this?

Report Abuse
LavanderLights is not online. LavanderLights
Joined: 21 Oct 2013
Total Posts: 3526
18 Mar 2015 01:40 PM
support
that is pretty ineffective
Report Abuse
ForeverDev is not online. ForeverDev
Joined: 04 Oct 2008
Total Posts: 13300
18 Mar 2015 01:41 PM
thanks

bump
Report Abuse
ForeverDev is not online. ForeverDev
Joined: 04 Oct 2008
Total Posts: 13300
18 Mar 2015 01:48 PM
buuump
Report Abuse
ForeverDev is not online. ForeverDev
Joined: 04 Oct 2008
Total Posts: 13300
18 Mar 2015 01:51 PM
so many views
so few replies
Report Abuse
ForeverDev is not online. ForeverDev
Joined: 04 Oct 2008
Total Posts: 13300
18 Mar 2015 02:07 PM
bbuukmmmpp
Report Abuse
UndefinedVariable is not online. UndefinedVariable
Joined: 15 Mar 2013
Total Posts: 4632
18 Mar 2015 02:11 PM
local function WaitForChild(Parent, Name)
repeat wait() until Parent:FindFirstChild(Name)
return Parent:FindFirstChild(Name)
end

what to heck
Report Abuse
Aluminize is not online. Aluminize
Joined: 27 Sep 2014
Total Posts: 209
18 Mar 2015 02:12 PM
a
Report Abuse
Q5C is not online. Q5C
Joined: 18 Sep 2012
Total Posts: 8221
18 Mar 2015 02:13 PM
go to scripters forum

we are too dumb for this
Report Abuse
Kipec is not online. Kipec
Joined: 25 Nov 2010
Total Posts: 10272
18 Mar 2015 02:13 PM
wat does this even do
Report Abuse
ForeverDev is not online. ForeverDev
Joined: 04 Oct 2008
Total Posts: 13300
18 Mar 2015 02:13 PM
@undefined

that's inefficient and i don't wanna do that
Report Abuse
UndefinedVariable is not online. UndefinedVariable
Joined: 15 Mar 2013
Total Posts: 4632
18 Mar 2015 02:14 PM
And, if you're going to be using that function in multiple scripts, just use a ModuleScript.

what to heck
Report Abuse
UndefinedVariable is not online. UndefinedVariable
Joined: 15 Mar 2013
Total Posts: 4632
18 Mar 2015 02:15 PM
Yeah, but it looks better than what you came up with, AND it's what ROBLOX used before :WaitForChild was implemented.

what to heck
Report Abuse
ForeverDev is not online. ForeverDev
Joined: 04 Oct 2008
Total Posts: 13300
18 Mar 2015 02:16 PM
I still think if ROBLOX is going to implement a method they should atleast get it to work.
Report Abuse
UndefinedVariable is not online. UndefinedVariable
Joined: 15 Mar 2013
Total Posts: 4632
18 Mar 2015 02:23 PM
Do you have FilteringEnabled?

what to heck
Report Abuse
ForeverDev is not online. ForeverDev
Joined: 04 Oct 2008
Total Posts: 13300
18 Mar 2015 02:24 PM
no
Report Abuse
Tripane is not online. Tripane
Joined: 03 Jun 2011
Total Posts: 11432
18 Mar 2015 02:25 PM
repeat wait() until hierarchy.object
object = hierarchy.object

works for me
Report Abuse
UndefinedVariable is not online. UndefinedVariable
Joined: 15 Mar 2013
Total Posts: 4632
18 Mar 2015 02:29 PM
It's not a ROBLOX bug, it works fine for me.

Server:
game.Players.PlayerAdded:connect(function(Player)
wait(10)
local s = Instance.new('IntValue', Player)
s.Name = 'test'
end)

Client:
local p = game:GetService('Players').LocalPlayer
local v = p:WaitForChild('test')

print(v)

> test

what to heck
Report Abuse
xXxXxdragonxXxXx is not online. xXxXxdragonxXxXx
Top 100 Poster
Joined: 30 Dec 2008
Total Posts: 30113
18 Mar 2015 02:35 PM
I'm fairly sure, as a C++ programmer, that RBX Lua's WaitForChild is just as fast as C++. The only exception is that there's a minimum seconds for wait function, which is reasonable because it'll prevent the server or client crashing. Just take this for instance: repeat until death -- literally a crash script. 3 stupid words.

Technically there'd be a wait there, but let's say that there's no minimum seconds being enforced.

Anyway, to the point: I'm absolutely sure that the WaitForChild function's source code is this...

local object
repeat wait() object = self:FindFirstChild(name) until object
return object

self being the object, table, or even metatable it refers to, it's called Object Oriented style, i.e.

local Table = { };
function Table:Add(mixed)
table.insert(self, mixed);
end;
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Roblox » All Things ROBLOX
   
 
   
  • 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