You can write your topic however you want, but you need to answer these questions:
What do you want to achieve?
I want to make a custom function “:GetName()”
What is the issue? Include screenshots / videos if possible!
I dont know how to make a custom function :GetName()
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local workspace = workspace
workspace:GetName()
--Output "Workspace"?
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.
local Object = {}
Object.__index = Object
function Object.new(Part)
local self = setmetatable({}, Object)
self.Object = Part
return self
end
function Object:GetFullName()
return self.Object:GetFullName()
end
return Object
–Normal script
local ObjectModule = require(game.ServerStorage.ModuleScript)
local Part = ObjectModule.new(workspace.Part)
Part:GetFullName()
This example above is pretty useless but you can do much more powerful things with it.
In your second script, does m = module? (aka table). Then you pass “m” as the first argument to GetName function with workspace and from that you get the instance’s name printed?
This is not a function, this is a method. Whenever you use the colon after a object you are calling a method attached to that object.
Example:
BasePart:Destroy()
Destroy is a method of basepart. To make your custom method you would need to learn object oriented programming. You create your own object like basepart and attach custom methods to thay object. There are many great tutorials and forums for this. Your not attaching the method to a pre existing object. For your solution make a custom function that simply gets the workspaces name and returns it.
Example:
local function GetWorkspaceName()
return workspace.Name
end
<< methods are basically functions attached to objects and methods are the correct name but functions could work too.
You don’t do method newMethod() when creating a new method/function though? You instead do function newMethod(). But methods AND functions are the correct names, not just methods.
Methods like part:destroy are technically functions. but they are only attached to that specific object You can read the descriptions it says “sets the parts parent to nil and disconnects all functions connected to that object” and methods are the correct name all because they are the same colour in default theme does not mean they are the same.
When you use the colon it automatically passes the object (part) as self you should learn about OOP it will help you get a better understanding.
Here is link where you can read about functions it explains methods at the bottom
Edit wth i didnt even realize this was four years ago i just saw it on latest