I would like Feedback on my own custom modulescript on making my own built in functions (work in progress) I hope you guys like this, if you would like this here is my rbxm file:
MainFunctionsModule.rbxm (1.7 KB)
Or you can look at the script here:
-- Custom Built-in-functions Module
local functionMod = {}
function functionMod:FindFirstDescendantOfClass(instancePart,class)
for _, part in pairs(instancePart:GetDescendants()) do
if part:IsA(class) then
print("Found " .. class .. " with the name of " .. part.Name)
break
elseif not part:IsA(class) then
warn(part.Name .. ":" .. " is not a " .. class)
end
end
end
function functionMod:BreakAttachments(instancePart)
for _, attach in pairs(instancePart:GetDescendants()) do
if attach:IsA("Attachment") then
print(attach.Name .. ":" .. " Destroyed")
attach:Destroy()
elseif not attach:IsA("Attachment") then
warn(attach.Name .. ":" .. " is not a Attachment")
end
end
end
function functionMod:PrintTable(tableName)
for tableKey, tableVal in pairs(tableName) do
print(tableKey .. ":", tableVal)
end
end
function functionMod:Visibility(instancePart,amount)
instancePart.Transparency = tonumber(amount)
end
function functionMod:MultiClone(instancePart,waitTime,cloneAmount,parent)
local cloned = 0
while wait(waitTime) do
if cloned >= tonumber(cloneAmount) then
break
end
cloned += 1
instancePart:Clone().Parent = game:FindFirstChildOfClass(parent)
end
end
function functionMod:ChangeColor(instancePart,color)
instancePart.BrickColor = color
end
function functionMod:WaitForChildOfClass(instancePart,class)
for _, value in pairs(instancePart:GetDescendants()) do
repeat wait() until value:IsA(class)
print(value.Name)
end
end
function functionMod:PartPosition(instancePart,part)
if instancePart and part then
instancePart.Position = part.Position
end
end
function functionMod:DestroyAllChildren(instancePart)
for _, child in pairs(instancePart:GetChildren()) do
if child then
child:Destroy()
end
end
end
function functionMod:TeleportTo(instancePart,part)
if instancePart and part then
if instancePart:IsA("Model") and part:IsA("Part") or part:IsA("UnionOperation") or part:IsA("MeshPart") then
if instancePart.PrimaryPart then
instancePart:SetPrimaryPartCFrame(part.CFrame)
else
warn("Model needs PrimaryPart to call this function!")
end
end
end
end
function functionMod:SetGravity(gravity)
game.Workspace.Gravity = tonumber(gravity)
end
function functionMod:FindPlayer()
for _, player in pairs(game.Players:GetPlayers()) do
if player then
return player
end
end
end
return functionMod
Would love critisism on my script.
(I am new to scripting)