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 » Scripting Helpers
Home Search
 

Check if something is an instance?

Previous Thread :: Next Thread 
Lukekneenew is not online. Lukekneenew
Joined: 20 Oct 2009
Total Posts: 746
15 May 2013 05:04 PM
How would you do this? I can't do thingy:IsA("Instance") because you can only do that with instances.
Report Abuse
notsopwnedg is not online. notsopwnedg
Joined: 07 Nov 2010
Total Posts: 4182
15 May 2013 05:07 PM
What?
If your trying to figure out if a variable hold a instance then you could do:

local IsInstance = function(Thing)
if pcall(function() print(Thing.Name) end) then
return true
else
return nil
end
end

local Bob = Workspace.Part
local Joe = "kdsa"
print(IsInstance(Bob))
print(IsInstance(Joe))

>True
>False
Report Abuse
Lukekneenew is not online. Lukekneenew
Joined: 20 Oct 2009
Total Posts: 746
15 May 2013 05:08 PM
Thanks.
Report Abuse
BlueTaslem is not online. BlueTaslem
Joined: 11 May 2008
Total Posts: 11060
15 May 2013 05:09 PM
What else might it be?

type(obj)

would be

"userdata"

Though this will also be true for CFrame, Vector3, UDim2.
Report Abuse
notsopwnedg is not online. notsopwnedg
Joined: 07 Nov 2010
Total Posts: 4182
15 May 2013 05:10 PM
newproxy returns a userdata also.
Report Abuse
BlueTaslem is not online. BlueTaslem
Joined: 11 May 2008
Total Posts: 11060
15 May 2013 05:15 PM
Garbage in, garbage out; if he's planning on trying to be confusing then that's what you'd expect.


The function you provided similarly fails for

{Name = {12,87}}

and also annoyingly prints to output.
Report Abuse
BlueTaslem is not online. BlueTaslem
Joined: 11 May 2008
Total Posts: 11060
15 May 2013 05:18 PM
function instance(inst)
local a = pcall(
function()
local b = game.IsA(inst,"Instance");
end
);
if not a then
return false;
end
return game:IsA(inst,"Instance");
end


This ought to have no holes.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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