Pretty much what I wanna do is be able to give a Part it's own function.
for example: workspace.Part:Nil()
or
workspace.Part:Boom()
Is there anyway I can attempt this? I've tried just doing this:
1 | function Item:Nil() |
2 | Item.Parent = nil |
3 | end |
(I didn't think that'd work but I tried)
This might not be possible. But if there is anyway to make a "metatable" for a part then maybe it is possible (doubt it) Thank you for the help. If you can't find any way to do it that's fine.
This isn't possible. Roblox doesn't allow us to customly bind functions to objects. If you were using a more open engine (f.i. Unity / Unreal Engine), you could implement those custom functions.
For your Objet:Nil() function, you should use:
1 | function Nil(Object) |
2 | if Object then |
3 | Object = nil |
4 | end |
5 | end |
6 |
7 | Nil(MyObject) |
Or just the simple one line: Object:Destroy()
For your Object:Boom() function, you can make
1 | function Boom(Object) |
2 | if Object:IsA( "BasePart" ) then |
3 | Instance.new( "Explosion" ,game.Workspace).Position = Object.Position |
4 | end |
5 | end |
6 |
7 | Boom(MyObject) |
This will create an explosion at the Position of MyObject.