diff --git a/crates/lune-roblox/src/instance/base.rs b/crates/lune-roblox/src/instance/base.rs index 58a2ae7..4b737d3 100644 --- a/crates/lune-roblox/src/instance/base.rs +++ b/crates/lune-roblox/src/instance/base.rs @@ -113,7 +113,6 @@ pub fn add_methods<'lua, M: LuaUserDataMethods<'lua, Instance>>(m: &mut M) { }, ); m.add_method("IsA", |_, this, class_name: String| { - ensure_not_destroyed(this)?; Ok(class_is_a(&this.class_name, class_name).unwrap_or(false)) }); m.add_method( @@ -217,19 +216,20 @@ fn instance_property_get<'lua>( this: &Instance, prop_name: String, ) -> LuaResult> { - ensure_not_destroyed(this)?; - match prop_name.as_str() { "ClassName" => return this.get_class_name().into_lua(lua), - "Name" => { - return this.get_name().into_lua(lua); - } "Parent" => { return this.get_parent().into_lua(lua); } _ => {} } + ensure_not_destroyed(this)?; + + if prop_name.as_str() == "Name" { + return this.get_name().into_lua(lua); + } + if let Some(info) = find_property_info(&this.class_name, &prop_name) { if let Some(prop) = this.get_property(&prop_name) { if let DomValue::Enum(enum_value) = prop { diff --git a/crates/lune-roblox/src/instance/mod.rs b/crates/lune-roblox/src/instance/mod.rs index 3397e09..120a514 100644 --- a/crates/lune-roblox/src/instance/mod.rs +++ b/crates/lune-roblox/src/instance/mod.rs @@ -302,10 +302,7 @@ impl Instance { pub fn get_parent(&self) -> Option { let dom = INTERNAL_DOM.lock().expect("Failed to lock document"); - let parent_ref = dom - .get_by_ref(self.dom_ref) - .expect("Failed to find instance in document") - .parent(); + let parent_ref = dom.get_by_ref(self.dom_ref)?.parent(); if parent_ref == dom.root_ref() { None