Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- CHL's functions
- by CHL/SoftlockedUnderZero
- Place code in a module script.
- Here comes obnoxious comments lol
- This script will include:
- + a Services dictionay
- + a coroutine2 library
- + run
- + an Instance2 libary
- + new
- + new2
- + a math2 library
- + average
- + euler
- + round
- + round2
- + a table2 library
- + add
- + changevalues
- + changevalues2
- + foreach
- + foreacha
- + foreachi
- + getindexes
- + len
- + lena
- + randomvalue
- + replicate
- + a remote library
- + RemoteArray
- + GetRemoteEvent
- + GetRemoteFunction
- + FireServer
- + FireClient
- + InvokeServer
- + InvokeClient
- + FireAllClients
- + ServerHandler
- + ClientHandler
- + a string2 library
- + replace
- + multisplit
- + StringToByte
- + global apairs function
- + global wait2 function
- + global spawn2 function
- + global delay2 function
- + global DecalIdToImageId function
- + global GetPlayerFromSubString function
- + global toboolean function
- + global WaitForChild function
- + global ProcessReciept2 function
- + global WaitForChildWhichIsA function
- + global LoadstringEnabled function
- + global LoadLibrary2 function
- + global MethodToContructorFunction function
- + global IsVSB function
- + global ContentURL string
- + global GetObjects2 function
- + global GetPlayerFromCharacterDescendant function
- + global FindFirstChildren function
- + global WaitForAncestorWhichIsA function
- + global TeleportCharacter function
- + global TeleportAllCharacters function
- + global YieldUntil function
- + global PlayerHandler function
- + global CharacterHandler function
- + global tocontentstring function
- + global DamagePart function
- + global CheckVariable function
- + global printtable function
- + global CheckGlobalVariable function
- + global effects library
- + Text section
- + Typewriter effect
- + global GetUpdatedName function
- + global CFrame2 library
- + AnglesRad
- + PositionOrientationToCFrame function In testing
- + CFrameToPositionOrientation function In testing
- + PhysicsServiceFunctions library
- --]]
- local CHL_Functions = {
- Services = { -- Services table
- Players = game:GetService("Players");
- RunService = game:GetService("RunService");
- MarketplaceService = game:GetService("MarketplaceService");
- ReplicatedStorage = game:GetService("ReplicatedStorage");
- UserInputService = game:GetService("UserInputService");
- KeyframeSequenceProvider = game:GetService("KeyframeSequenceProvider");
- ServerStorage = game:GetService("ServerStorage");
- PhysicsService = game:GetService("PhysicsService");
- HttpService = game:GetService("HttpService")
- };
- CFrame2 = {
- AnglesRad=function(x,y,z)local a=math.rad;return CFrame.Angles(a(x),a(y),a(z))end;
- };
- coroutine2 = {
- run = function(a)local b = coroutine.wrap(a);b();return b;end;
- --[[It's a quicker way of saying .wrap(func)(), except it also returns the thread.
- Arguments:
- M (function)
- Returns:
- (thread)
- --]]
- };
- effects = {
- Text = {
- Typewriter = function(text,waitincrementtime,nospaceyield,object,property)
- local function d(b,c)
- for a=1,#text do
- local letter = text:sub(a,a);
- b[c] = text:sub(1,a);
- if nospaceyield and letter==' 'then continue;end;
- wait(waitincrementtime);
- end;
- end;
- if object and property then
- d(object,property)
- else
- return d;
- end;
- end;
- --[[Yielding current script, this types each letter one by one until the result is finished.
- If unprovided an object, then it will return a function instead.
- Arguments:
- M (string)
- M (number)
- O (boolean-type)
- O (Instance)
- O (string)
- Returns:
- (If unprovided an instance and property)
- (function) With parameters equal to the fourth and fifth original parameters.
- --]]
- };
- };
- Instance2 = {};
- math2 = {
- euler = 2.7182818284590452353602874713527;
- --//euler's constant number (shorted because the real number is irrational like math.pi)
- round = function(a)return math[a<math.ceil(a)-.5 and'floor'or'ceil'](a)end
- --[[This function rounds to the ones place. Note: to round to other number places you have
- to either use math2.round2 or do the math outside of the function
- Arguments:
- M (number)
- Returns:
- M (number)
- --]]
- };
- PhysicsServiceFunctions = {};
- remote = {RemoteArray = {Instance.new("RemoteEvent");Instance.new('RemoteFunction');};};
- string2 = {
- replace = function(main,replacements)for a,b in pairs(replacements)do main=string.gsub(main,a,b);
- end;return main;end;
- --[[Functions like gsub but you can replace mulitple words as one dictionary.
- Arguments:
- M (string)
- M (table) A Dictionary where the index is the target string and the value is the new
- replacement
- Returns:
- M (string) The new result.
- --]]
- multisplit = function(a,...)a={a;};for _,b in pairs{...;}do local c={};for _,d in pairs(a)do
- local g=string.split(d,b);for f,e in pairs(g)do table.insert(c,e);if #g==f then continue;end;
- table.insert(c,b);end;end;a=c;end;if not table.find({...;},'')then local d={};for b,c in pairs(a)
- do if c~=''then continue;end;table.insert(d,b);end;for b in pairs(d)do table.remove(a,d[#d-b+1]);
- end;end;return a;end;
- --[[Like string.split, it returns an array. But it also returns values that also include the
- seperator. You can also put more than one seperator in the tuple arguments.
- Arguments:
- M (string)
- M (tuple) All strings.
- Returns:
- (table)
- --]]
- StringToBytes=function(string_1)return'\\'.. table.concat({string.byte(string_1,1,#string_1),'\\'})end;
- --[[Returns a string where the string is converted to byte already formatted with the backward slashes
- Arguments:
- M (string)
- Returns:
- (string)
- --]]
- };
- table2 = {
- add = function(table1)local b = 0;for _,a in pairs(table1)do b = b + a;end;return b;end;
- --[[Adds each value of a given table and gives the sum.
- Arguments:
- M (table) table_of_numbers
- Returns:
- (Number) The sum of each value
- --]]
- changevalues = function(table1,newvalues,isprinted)for a,b in pairs(newvalues)do
- local _,c=pcall(function()table1[a]=b;end);if isprinted and c then warn('So'
- ..'mething went wrong while changing a value: Index = '..a..', Value = '..b);end;end;end;
- --[[Changes the table's index with the new value. Similar with Table.Index = Value, except it
- can be done with a table.
- Arguments:
- M (table) Table_that_will_be_changing (or instance)
- M (table) Table_that_will_do_the_changing
- O (boolean-type) If true, then the function will warn if something went wrong.
- --]]
- foreach = function(table_a,function_a)local c = {};for a,b in pairs(table_a)do c[a] = function_a(a,b);
- end;return c;end;
- --//Functions and structured like table.foreach except it returns a table of results and can yield
- foreachi = function(table_a,function_a)local c = {};for a,b in ipairs(table_a)do c[a] = function_a(a,b);
- end;return c;end;
- --//Functions and strucured like table.foreachi and has similar behavior like table2.foreach
- getindexes = function(a)assert(a,'argument 1 missing')local c = {};for b in pairs(a)do
- table.insert(c,b);end;return c;end;
- --[[Returns an array of each index from a given dictionary.
- Arguments:
- M (table)
- Returns:
- M (table)
- --]]
- replicate = function(table_a)local a = {};for b,c in pairs(table_a)do a[b]=c;end;return a;end;
- --[[Creates a new table with the index and values exactly like the old one.
- Arguments:
- M (table) Old table
- Returns:
- (table) New table
- --]]
- };
- toboolean = function(a)return not not a;end;
- --[[Returns a boolean-type value into a boolean.
- Arguments:
- O (Boolean-type)
- Returns:
- (boolean)
- --]]
- LoadstringEnabled = function(String)local a = pcall(function()loadstring'return""'();end);
- if not a then return;end;if String then return loadstring(String);end;return loadstring;end;
- --[[Returns nil if loadstring is not enabled, but returns the function if it is (depending on the first
- argument).
- Arguments:
- O (string) If there's a string, the function will return a loadstring called function, otherwise,
- it will return loadstring itself.
- Returns:
- (variant)
- (nil) Only if loadstring is not enabled.
- (function)
- > loadstring itself if the first argument is empty.
- > loadstring called with the string provided.
- --]]
- LoadLibrary2 = function()return require(4675891912);end;
- --[[Functions like loadlibrary but when called with "CloneSelf", it clones a module version of itself.
- Note: you have to call this first then call another time to apply arguments.
- Arguments:
- M (string) Same strings like loadlibrary plus "CloneSelf".
- Returns:
- (Variant) Same value returned like loadlibrary except if the string is "CloneSelf", it returns
- a module which can be required like this function itself, you can not use "CloneSelf" again.
- --]]
- GetArrayBasedOnClassName=function(a,b)local c={};for _,d in pairs(a)do if not d:IsA(b)then continue;
- end;table.insert(c,d);end;return c;end;
- --[[Returns an array from a given table which contains the classname given.
- Arguments:
- M (table)
- M (string) classname
- Returns:
- (table)
- --]]
- MethodToContructorFunction = function(a,b)return function(...)return a[b](a,...);end;end;
- --[[Converts a method to a constructure function. This does not change the table.
- Arguments:
- M (table)
- M (string)
- Returns:
- (function)
- --]]
- ContentURL = 'http://www.roblox.com/asset/?id=';
- };
- --// Instance2 \\--
- CHL_Functions.Instance2.new = function(ClassName,Properties)local a = Instance.new(ClassName);
- CHL_Functions.table2.changevalues(a,Properties or{},0);return a;end;
- --[[Creates a new instance with the second arg being that it changes the instances properties.
- Arguments:
- M (string) Classname of the instance.
- O (dictionary) A dictionary where the properties are changed.
- Returns:
- (Instance) Instance
- --]]
- CHL_Functions.Instance2.new2 = function(ClassName)return function(Properties)
- return CHL_Functions.Instance2.new(ClassName,Properties);end;end;
- --//Functions and structiured like LoadLibraries "Create" function
- --// math2 \\--
- CHL_Functions.math2.average = function(...)return CHL_Functions.table2.add{...;}/#{...;};end;
- --[[Returns the average of the tuple
- Arguments:
- M (tuple) ...
- Returns
- (number) the average from the sum from the tuple
- --]]
- --// table2 \\--
- CHL_Functions.table2.changevalues2 = function(table1,isprinted)return function(Properties)
- CHL_Functions.table2.changevalues(table1,Properties,isprinted)end;end;
- --//Same function as table2.changevalues but structured like LoadLibrary's Create.
- CHL_Functions.table2.foreacha = function(table1,function_a)for a,b in pairs(table1)do if tonumber(a)then
- continue;end;function_a(a,b);end;end;
- --//Structed like foreachi except it accepts a dictionary instead of arrays.
- CHL_Functions.table2.len = function(a)return#CHL_Functions.table2.getindexes(a);end;
- --[[Returns a number like operator # but it also includes both indexes and keys.
- Arguments:
- M (table)
- Returns:
- (number)
- --]]
- CHL_Functions.table2.lena=function(a)local b=0;for _ in CHL_Functions.apairs(a)do b=b+1;end;return b;end;
- --//Functions and structured like table2.len except it only counts indexes.
- CHL_Functions.table2.randomvalue=function(a)assert(a,'argument 1 missing');local c={};for _,b in pairs(a)do
- table.insert(c,b);end;return c[math.random(1,#c)];end;
- --[[Returns a random value from the array.
- Arguments:
- M (table)
- Returns:
- (variant) depends what's on the array.
- --]]
- --// remote \\--
- CHL_Functions.remote.GetRemoteEvent = function()
- return CHL_Functions.table2.randomvalue(CHL_Functions.GetArrayBasedOnClassName(CHL_Functions.remote.
- RemoteArray,'RemoteEvent'));end;
- --[[Returns a random remoteevent.
- Returns:
- (Instance) RemoteEvent
- --]]
- CHL_Functions.remote.GetRemoteFunction = function()
- return CHL_Functions.table2.randomvalue(CHL_Functions.GetArrayBasedOnClassName(CHL_Functions.remote.
- RemoteArray,'RemoteFunction'));end;
- --//Same thing as remote.GetRemoteEvent but returns a RemoteFunction
- CHL_Functions.remote.FireServer = function(...)CHL_Functions.remote.GetRemoteEvent():FireServer(...);end;
- CHL_Functions.remote.FireClient = function(...)CHL_Functions.remote.GetRemoteEvent():FireClient(...);end;
- CHL_Functions.remote.InvokeServer = function(...)
- return CHL_Functions.remote.GetRemoteFunction():InvokeServer(...);end;
- CHL_Functions.remote.InvokeClient = function(...)
- return CHL_Functions.remote.GetRemoteFunction():InvokeClient(...);end;
- CHL_Functions.remote.FireAllClients = function(...)
- CHL_Functions.remote.GetRemoteEvent():FireAllClients(...);
- end;
- --//It's self explainitory
- CHL_Functions.remote.ServerHandler = function(a)
- for _,b in pairs(CHL_Functions.remote.RemoteArray)do
- if b:IsA'RemoteEvent'then
- b.OnServerEvent:Connect(a);
- elseif b:IsA'RemoteFunction'then
- b.OnServerInvoke = a;
- end;
- end;
- end;
- CHL_Functions.remote.ClientHandler = function(a)
- for _,b in pairs(CHL_Functions.remote.RemoteArray)do
- if b:IsA'RemoteEvent'then
- b.OnClientEvent:Connect(a);
- elseif b:IsA'RemoteFunction'then
- b.OnClientInvoke = a;
- end;
- end;
- end;
- --[[This funciton is used to merge OnServerEvent and OnServerInvoke and viceversa with client functions
- if called differently
- --]]
- --// other globals \\--
- CHL_Functions.apairs = function(table_a)local b = pairs(table_a);local e = {};for c,d in pairs(table_a)do
- if typeof(c)=='number'then continue;end;e[c]=d;end;return b,e;end;
- --//Structured like "pairs" and "ipairs" except only runs on indexes of "strings" not numbers.
- CHL_Functions.spawn2 = CHL_Functions.coroutine2.run;
- --//Functions and structured exactly like roblox's "spawn", but faster.
- local spawn = CHL_Functions.spawn2;
- CHL_Functions.wait2 = function(WaitTime)--yes this is swait
- local Stepped = CHL_Functions.Services.RunService.Stepped;
- if not WaitTime or WaitTime==0 then local _,a = Stepped:Wait();return a;
- else local a = 0;repeat local _,b = Stepped:Wait();a=a+b;until a>=WaitTime;return a;end;end;
- --[[Similar to roblox's global "wait" except it uses runservice's Stepped to yield the current thread.
- Arguments:
- O (number) wait_time
- Returns:
- (number) amount of seconds passed
- --]]
- local wait = CHL_Functions.wait2;
- CHL_Functions.delay2 = function(WaitTime,function_a)spawn(function()wait(WaitTime);function_a();end);end;
- --//Functions and structured exactly like roblox's "delay".
- local delay = CHL_Functions.delay2;
- CHL_Functions.DecalIdToImageId = function(id)
- local GetProductId = function(a)return CHL_Functions.Services.MarketplaceService:GetProductInfo(a);end;
- local info = GetProductId(id);
- if info.AssetTypeId~=13 then return;end;
- local author = info.Creator.Name;
- repeat
- wait();
- id = id - 1;
- local newinfo = GetProductId(id);
- if newinfo.AssetTypeId~=1 then continue;end;
- if author~=newinfo.Creator.Name then continue;end;
- return id;
- until nil;
- end;
- --[[Returns the image id of a decal. This can yield the current thread.
- Arguments:
- M (number) Decal id.
- Returns:
- (number) Image id.
- --]]
- CHL_Functions.GetPlayerFromSubString = function(substring)assert(substring,'Argument 1 missing or nil');
- substring = substring:lower():reverse();for _,a in pairs(CHL_Functions.Services.Players:GetPlayers())do
- local b = (a.Name):lower():reverse();if not string.find(b,substring,#b-#substring)then continue;end;
- return a;end;end;
- --[[Returns a player from a given substring, returns nil if it can't find one. Ex, if the substring is
- 'potato' and a player named "potatowow" is here, then it returns the player, however, it will not return
- "wowpotato" because "potato" is at the end. Note: this does not account for the length of the name
- Arguments:
- M (string) Substring at the beginning of the target player's name.
- Returns:
- (Instance) Target Player.
- --]]
- CHL_Functions.WaitForChild = function(Parent,Name,TimeOut,GetDescendant,WaitTime)
- assert(Parent and Name,'Arguments missing.');
- local b = 0;
- repeat
- local a = Parent:FindFirstChild(Name,CHL_Functions.toboolean(GetDescendant));
- if a then return a;end;
- b = b + wait(WaitTime or 0);
- if TimeOut and TimeOut>b then return;end;
- until nil;
- end;
- --[[Yields current script and returns the child. Difference between this and the already implemented
- "WaitForChild" is that it won't throw a warning if you leave the timeout number blank.
- Arguments:
- M (Instance) Target Parent.
- M (string) Name.
- O (number) Time out in seconds.
- O (boolean-type) If true, it finds descendants.
- O (number) Increment for wait time.
- Returns:
- (Instance) Child
- --]]
- CHL_Functions.WaitForChildWhichIsA = function(Parent,ClassName,TimeOut,GetDescendant,WaitTime)
- assert(Parent and ClassName,'Arguments missing.');
- local b = 0;
- repeat
- local a = Parent:FindFirstChildWhichIsA(ClassName,CHL_Functions.toboolean(GetDescendant));
- if a then return a;end;
- b = b + wait(WaitTime or 0);
- if TimeOut and TimeOut>b then return;end;
- until nil;
- end;
- --[[Similar to WaitForChild except it uses classname instead of name.
- Arguments:
- M (Instance) Target Parent.
- M (string) ClassName.
- O (number) Time out in seconds.
- O (boolean-type) If true, it finds descendants.
- O (number) Increment for wait time.
- Returns:
- (Instance) Child
- --]]
- CHL_Functions.ProcessReciept2 = function(f)return function(a)
- return(f(a)and Enum.ProductPurchaseDecision.PurchaseGranted)or Enum.ProductPurchaseDecision.
- NotProcessedYet;end;end;
- --[[Similar to the original ProcessReceipt,except structured so that and false-type values will return
- Enum.ProductPurchaseDecision.NotProcessedYet and any true-type values will return
- Enum.ProductPurchaseDecision.PurchaseGranted
- Arguments:
- M (function)
- Returns:
- (function) now use this like ProcessReciept
- --]]
- CHL_Functions.IsVSB = function()return not not table.find({843495510;843468296;897312463;},game.PlaceId);end;
- --[[Returns a boolean if the specific script is in VSB.
- Returns:
- (boolean)
- --]]
- CHL_Functions.GetObjects2 = function(a)return game:GetObjects(CHL_Functions.ContentURL..a);end;
- --[[Functions like GetObjects except this function already concats the contenturl with the assetid
- --]]
- CHL_Functions.GetPlayerFromCharacterDescendant = function(a)
- if not a then return;end;
- a = a:FindFirstAncestorWhichIsA'Model';
- if not a then return;end;
- return CHL_Functions.Services.Players:GetPlayerFromCharacter(a);
- end;
- --//Returns the player if the instance is a descendant of their character.
- CHL_Functions.FindFirstChildren = function(Parent,Children)for _,a in pairs(Children)do
- Parent = Parent:FindFirstChild(a);if not Parent then return;end;end;return Parent;end;
- --[[Similar with FindFirstChild(...,'true') except it goes down the descendant tree to find it.
- Arguments:
- M (Instance) Parent
- M (Array) An array of strings of the name of the children.
- Returns:
- (Instance)
- --]]
- CHL_Functions.WaitForAncestorWhichIsA = function(Parent,Name,TimeOut,Increment)
- local b = 0
- repeat
- local a = Parent:FindFirstAncestorWhichIsA(Name);
- if a then return a;end;
- local c = wait(Increment or 1/60)
- b = b + c;
- if TimeOut then
- if b>=TimeOut then break;end;
- end;
- until nil;
- end;
- --//Self explanitory if you read the other functions.
- CHL_Functions.TeleportCharacter = function(Player,Position,CharacterOffset)
- assert(CHL_Functions.Services.RunService:IsClient(),'no')
- assert(Player and Position,'args 1 and 2 missing');
- local a = Player.Character;
- if typeof(Position)=='Instance'then Position = Position.CFrame;end;
- if CharacterOffset then Position = Position + Vector3.new(0,3,0);end;
- if not a then Player:LoadCharacter();a = Player.Character or Player.CharacterAdded:Wait();end;
- a = a:FindFirstChild'HumanoidRootPart';
- if not a then return;end;
- a.CFrame = Position;
- end;
- --[[Teleports the player's character to a position.
- Arguments:
- M (Instance) Player
- M (CFrame or Instance or Vector3) Position
- O (boolean-type) Automatically offsets character upwards if true.
- --]]
- CHL_Functions.TeleportAllCharacters = function(Position,Players,CharacterOffSet)
- assert(Position,'args 1 missing');
- for _,a in pairs(Players or CHL_Functions.Services.Players:GetPlayers())do
- CHL_Functions.TeleportCharacter(a,Position,CharacterOffSet);
- end;
- end;
- --[[Functions like TeleportCharacter but it can do all players or a specific set of them.
- Arguments:
- M (CFrame or Instance or Vector3) Position
- O (table) An array of players who have been chosen to get teleported.
- If blank, the array will be all players.
- O (boolean-type) Automatically offsets character upwards if true.
- --]]
- CHL_Functions.YieldUntil = function(ActionFunction,TimeOut,Increment,...)
- local a = 0;
- while''do
- local b = ActionFunction(...);if b then return b;end;
- a = a + wait(Increment or 0);if TimeOut and TimeOut<a then break;end;
- end;
- end;
- --[[Yields current thread and repeatedly calls the ActionFunction until the ActionFunction returns a value.
- Basically the same as:
- repeat
- -- ...
- until nil
- Arguments:
- M (function) Repeatedly called until a value is returned.
- O (number) Time out in seconds.
- O (Increment) Time it takes to call the next function after calling the previous one.
- O (tuple) Arguments used on the ActionFunction.
- Returns:
- (variant)
- --]]
- CHL_Functions.PlayerHandler = function(a)CHL_Functions.Services.Players.PlayerAdded:Connect(a);
- for _,b in pairs(CHL_Functions.Services.Players:GetPlayers())do a(b);end;end;
- --[[A function which is called for every player in the server and for each new player added.
- Arguments:
- M (function)
- --]]
- CHL_Functions.CharacterHandler = function(a)CHL_Functions.PlayerHandler(function(b)if b.Character then
- a(b.Character);end;b.CharacterAdded:Connect(a);end);end;
- --//Structured like PlayerHandler except called on the player's character or when a character is added.
- CHL_Functions.tocontentstring = function(a)return CHL_Functions.ContentURL..tostring(a);end;
- --//Returns a string form of content with the id.
- CHL_Functions.DamagePart = function(Part,Damage,ActionFunction,InstantDeathHealthCapacity,OnlyLimbs)
- assert(Part,'no part');Damage = Damage or 1;ActionFunction = ActionFunction or function()end;
- local a = (OnlyLimbs and Part.Parent)or Part:FindFirstAncestorWhichIsA'Model';if not a then return;end;
- local b = a:FindFirstChildWhichIsA'Humanoid'or a:FindFirstChild('Head')or a:FindFirstChid('Torso')or
- a:FindFirstChild'UpperTorso';
- if b then
- if b:IsA'BasePart'then b:Destroy();ActionFunction();
- elseif b:IsA'Humanoid'then b:TakeDamage(Damage);
- if InstantDeathHealthCapacity and b.Health>InstantDeathHealthCapacity then b.Health = 0;end;
- ActionFunction();end;
- else pcall(function()b:BreakJoints();ActionFunction();end);end;
- end;
- --[[Damages the character but better. Any part which is a descendant of the character will get damaged
- and not its children. The function also provides an action function which is called when the character
- has been successfully damaged. DamagePart also provides a max health capacity which instantly kills the
- player if their health is over the parameter and an onlylimbs parameter which reduces the hitbox of the
- character from the character with accessories to just the character itself.
- Arguments:
- M (Instance)
- O (Number)
- O (function)
- O (number)
- O (boolean-type)
- --]]
- CHL_Functions.CheckVariable = function(a)
- assert(CHL_Functions.LoadstringEnabled(),'loadstring not enabled, unable to use this');
- return loadstring('return '..a)();
- end;
- --[[Returns the variable regardless whether its local and global. Difference is that the variable is writen as a
- string and the variable must be in the block. There will be no warnings in the script.
- Arguments:
- M (string)
- Returns:
- (variant)
- --]]
- CHL_Functions.printtable = function(a)CHL_Functions.table2.foreach(a,print);end;
- --[[Prints the table with key and value side to side. Mainly used for debuging purposes.
- Arguments:
- M (table)
- --]]
- CHL_Functions.CheckGlobalVariable = function(a)return getfenv()[a];end;
- --//Same as CheckVariable but only for globals. The upside is that it does not require loadstring.
- CHL_Functions.GetUpdatedName = function(a)local b=CHL_Functions.Services.Players;
- return b:GetNameFromUserIdAsync(b:GetUserIdFromNameAsync(a));
- end;
- --[[Returns the current updated name from an input of an old name
- Parameters:
- M (string)
- Returns:
- (string)
- --]]
- CHL_Functions.CFrame2.PositionOrientationToCFrame=function(p,o)local a,b=CFrame,CHL_Functions.CFrame2.AnglesRad;
- return a.new(p)*b(0,0,o.Z)*b(0,o.Y,0)*b(o.X,0,0);
- end;
- CHL_Functions.CFrame2.CFrameToPositionOrientation=function(c)local a,b,d={c:GetComponents()},Vector3.new,math.deg;
- local c={c:ToOrientation()}return b(a[1],a[2],a[3]),b(d(c[1]),d(c[2]),d(c[3]));
- end;
- CHL_Functions.PhysicsServiceFunctions.FindGroup = function(name)
- local a = CHL_Functions.Services.PhysicsService;
- for _,b in next,a:GetCollisionGroups()do
- if b.name==name then
- return b;
- end;
- end;
- end;
- CHL_Functions.PhysicsServiceFunctions.CreateGroup = function(name)
- local a = CHL_Functions.Services.PhysicsService;
- local b = CHL_Functions.PhysicsServiceFunctions.FindGroup(name)
- if b then return b;end;
- return a:CreateCollisionGroup(name)
- end
- CHL_Functions.math2.round2 = function(a,b)b=10^(b or 0)return CHL_Functions.math2.round(a*b)/b;end
- --[[Same function as math2.round but with a new parameter where the number is muliplied with 10 ^ x beforehand
- so that math2.round can run to a specific number place
- Arguments:
- M (number)
- O (number)
- Returns:
- --]]
- return CHL_Functions;
Add Comment
Please, Sign In to add comment