Alright I’m on it! Thanks for the quick reply!
Welding between two parts
ex:
function module:WeldBetween(part0, part1)
local w = Instance.new("Weld")
w.P0 = part0
w.P1 = part1
w.C0 = part0.CFrame * part1.CFrame:inverse()
w.Parent = part0
return w
end
Another useful function would be a method to get a list of characters given a collection of parts (such as when you use workspace:FindPartsInRegion3()
ex:
function module:FindCharactersInList(list)
local chars = {}
local foundChars = {}
for _, part in next, list do
if part.Parent:FindFirstChild"Humanoid" and not foundChars[part.Parent.Humanoid] then
foundChars[part.Parent.Humanoid] = true
chars[#chars+1] = part.Parent.Humanoid
end
end
return chars
end
(Returns an array of characters, no duplcates)
I’m so glad someone is doing this! I though about doing something like this but never got around to doing it. I don’t know if this fits into the idea you had for the module but, you could add a leaderstat maker. Or maybe a easy way to create a new instance. Something module:Make(type, parent). I know that this is kind of pointless as it would be easier to use Intance.new. But, with Instance.new you have to put the parent after the obj is instantiated. But with this function you could shorten it to make it a little bit faster. I know that I would use it but I don’t know if it would help anyone or if it would be even effective. It’s just an idea.
Instance.new(instance, parent) is valid.
@GamingBroCoolkid328
Instance.new(instance, parent, CFrame) might be nice
:Clone() however does not have the option
so a
:Clone(parent) and
:Clone(parent, CFrame) are options
It isn’t efficient to do this. It is much more efficient to create the Instance, set all of its values, then set the Parent.
This article explains it in detail: Article
Yes, this is why I said the function would set the parent to make it easier than instantiating the obj then later setting the parent.
Not sure if it would fit every scripter but I’d definitely find a utility which hooks into ChatService and allows you to send messages to players without having to deal with channels and speakers useful
Finished on the leaderstat creator, you can now make leaderstats with ease!
function module:GetModelMass(model)
local Mass = 0
for _,descendant in pairs(model:GetDescendants()) do
if (descendant:IsA("BasePart")) then
Mass = Mass + descendant:GetMass()
end
end
return Mass
end
Interesting, good to know.
Thank you.
Not a function, but separate your utilities by type/task/so on so developers can salvage and use parts independent of the grand ModuleScript. Cluttering all kinds of functions into a single ModuleScript can and will get annoying not only for you as a maintainer but a developer as a user of this as well.
Cool! Hopefully it will prove useful! Also, do you have a estimated time for when the module will be finished?
Something I have in my module that I’m sure will be useful:
A function that returns the server type; normal, vip or reserved. If it’s a vip server potentially also the server owner. If I had access to my laptop right now I’d provide my code but it’s a bit late.
Extra table functions. Such as contains and count (for tables that contain strings for keys)
It may be a bit better because the second argument of Instance.new is not recommended to use (according to a DevForum article). Upon reading this article, I completely ended my habit of using the second argument. It would be a very simple function to run. (The article is from around two and a half years old, so I may be incorrect.)
A function I use a lot is this table randomizer, takes a table as input and returns the same table but the contents inside of it randomized.
function RandomizeTable(tbl)
local newt = {}
for i = 1, #tbl do
local n = math.random(1, #tbl)
table.insert(newt, tbl[n])
table.remove(tbl, n)
end
return newt
end
It’s great that you’re doing this! I don’t know if your module already has the following functions, but one that I know is used a lot is to shorten a number by using SI prefix symbols along with one that keeps a set number of decimals.
Here are some other simple functions that I have in my own module:
- Convert dictionary to array
- Return the object with the specified value at the designated key in an array of objects (dictionaries)
Basicly math functions but for vectors.
So math.vectorClamp(v,minv,maxv); math.vectorEquals(v0,v1); math.vectorLowerThan(v0,v1); math.vectorLowerEquals(v0,v1)
you get the point. Functions like these would be amazing to have and it’s a real bummer that we don’t have them by default. A must have in the module in my opinion!
If you want to get so far with it I will suggest you to make a part:GetPartsWelded()
that will return all the parts that are relying on that part for welds.