diff --git a/CHANGELOG.md b/CHANGELOG.md index a652b8d..6e912c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Remodel Changelog ## Unreleased Changes +* **Breaking:** `Instance.new` now only works for instances that actually exist. * Added `Instance:Clone()` for copying instances all over the place, as is Roblox tradition. ([#12](https://github.com/rojo-rbx/remodel/issues/12)) * Added `DataModel:GetService()` for finding services and creating them if they don't exist, like Roblox does. * Improved error messages in preparation for [#7](https://github.com/rojo-rbx/remodel/issues/7) to be fixed upstream. diff --git a/src/roblox_api/mod.rs b/src/roblox_api/mod.rs index 162b56e..da5d526 100644 --- a/src/roblox_api/mod.rs +++ b/src/roblox_api/mod.rs @@ -20,6 +20,13 @@ struct Instance; impl UserData for Instance { fn add_methods<'lua, M: UserDataMethods<'lua, Self>>(methods: &mut M) { methods.add_function("new", |context, class_name: String| { + if rbx_reflection::get_class_descriptor(&class_name).is_none() { + return Err(rlua::Error::external(format!( + "'{}' is not a valid class of Instance.", + class_name, + ))); + } + let master_tree = RemodelContext::get(context)?.master_tree; let mut master_handle = master_tree.lock().unwrap();