Advertisement
KracKenYT

UsefulModule by Zakres

Mar 19th, 2023 (edited)
764
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 11.80 KB | Source Code | 0 0
  1. local usefulModule = {} --[[SCRIPTED BY ZAKRESDEV]]--
  2. local suffixes = {"", -- These are all of the suffixes for big numbers
  3.     "K",
  4.     "M",
  5.     "B",
  6.     "T",
  7.     "Qd",
  8.     "Qn",
  9.     "Sx",
  10.     "Sp",
  11.     "Oc",
  12.     "No",
  13.     "Dc",
  14.     "Ud",
  15.     "Dd",
  16.     "Td",
  17.     "Qad",
  18.     "Qid",
  19.     "Sxd",
  20.     "Spd",
  21.     "Ocd",
  22.     "Nvd",
  23.     "Vg",
  24.     "Uvg",
  25.     "Dvg",
  26.     "Tvg",
  27.     "Qavg",
  28.     "Qivg",
  29.     "Sxvg",
  30.     "Spvg",
  31.     "Ocvg",
  32.     "Novg"}
  33. local folder = script:WaitForChild("UsefulModule_Hitboxes"):Clone()  -- Clones the folder
  34. folder.Parent = workspace -- Parents the folder to the Workspace
  35. usefulModule.PlayAnimation = function(humanoid, animationID, animationSpeed) -- Creates a function called "PlayAnimation"
  36.     local animation = Instance.new("Animation") -- Creating an animation
  37.     animation.AnimationId = "rbxassetid://"..animationID -- Settings the ID of it to the argument sent trough the function
  38.     local track = humanoid:LoadAnimation(animation) -- Loading the animation using the a humanoid
  39.     track:Play() -- Playing the animation
  40.     track:AdjustSpeed(animationSpeed) -- Adjusting its speed with the value sent trough the function
  41. end
  42. usefulModule.CreateHitbox = function(duration, anchored, canCollide, cframe) -- Creates a function called "CreateHitbox"
  43.     local hitbox = Instance.new("Part", folder) -- Creates a part
  44.     game:GetService("Debris"):AddItem(hitbox, duration) -- Destroys it after the duration
  45.     hitbox.Anchored = anchored -- Sets the part to unanchored / anchored
  46.     hitbox.CanCollide = canCollide -- Sets the part CanCollide property to false / true
  47.     hitbox.CFrame = cframe -- Sets the position and orientation of the hitbox
  48. end
  49. usefulModule.PartRain = function(totalAmount, shape, material, anchored, canCollide, color3fromRGB, height) -- Creates a function called "PartRain"
  50.     local partsFolder = Instance.new("Folder", workspace) -- Creates a folder
  51.     partsFolder.Name = "RainingParts" -- Renames the folder to "RainingParts"
  52.     for count = 1, totalAmount do -- Creates a loop
  53.         local part = Instance.new("Part", partsFolder) -- Creates a part inside the folder
  54.         part.Position = Vector3.new(math.random(-250,250), height, math.random(-250,250)) -- Sets the Part's position to something random
  55.         part.Anchored = anchored -- Sets the part to unanchored / anchored
  56.         part.CanCollide = canCollide -- Sets the part CanCollide property to false / true
  57.         part.Shape = shape -- Sets the part Shape property to Ball / Block / Cylinder
  58.         part.Color = color3fromRGB -- Sets the part Color property to the color sent trough the function
  59.         part.Material = material -- Sets the part Material property to the material sent trough the function
  60.         wait(0.1) -- Creates a cooldown for the loop of 0.1 seconds.
  61.     end
  62. end
  63. usefulModule.KillingBoulder = function(damage, cframe, duration, size, material, shape, color3fromRGB) -- Creates a function called "KillingBoulder"
  64.     local hits = {} -- Creates an empty table
  65.     local boulder = Instance.new("Part", workspace) -- Creates a Part
  66.     game:GetService("Debris"):AddItem(boulder, duration) -- Destroys the Part after the duration
  67.     boulder.Name = "UsefulModule_Boulder" -- Renames the part to "UsefulModule_Boulder"
  68.     boulder.Size = size -- Sets the size to the size sent trough the function
  69.     boulder.Material = material -- Sets the part Material property to the material sent trough the function
  70.     boulder.Color = color3fromRGB -- Sets the part Color property to the color sent trough the function
  71.     boulder.CFrame = cframe -- Sets the position and orientation of the hitbox
  72.     boulder.Shape = shape -- Sets the part Shape property to Ball / Block / Cylinder
  73.     boulder.Touched:Connect(function(hit) -- Calls a function when the boulder is touched
  74.         if hit then -- Checks if it did get touched
  75.             if hit.Parent:FindFirstChild("Humanoid") then -- Checks if the hit is a humanoid
  76.             if table.find(hits, hit.Parent) then return -- Checks if the humanoid is already in the table
  77.                 else -- If the humanoid isn't in the table yet then...
  78.                     hit.Parent:FindFirstChild("Humanoid"):TakeDamage(damage) -- Damages the humanoid
  79.                     table.insert(hits, hit.Parent) -- Adds the humanoid inside the table so it doesn't get damaged anymore
  80.                 end
  81.             end
  82.         end
  83.     end)
  84. end
  85. usefulModule.CreateLeaderstats = function(player) -- Creates a function called "CreateLeaderstats"
  86.     local leaderstats = Instance.new("Folder", player) -- Creates a folder inside the player
  87.     leaderstats.Name = "leaderstats" -- Renames the folder to "leaderstats"
  88.     local coins = Instance.new("NumberValue", leaderstats) -- Creates a NumberValue
  89.     coins.Name = "Coins" -- Renames the NumberValue to "Coins"
  90.     local power = Instance.new("NumberValue", leaderstats) -- Creates a NumberValue
  91.     power.Name = "Power" -- Renames the NumberValue to "Power"
  92.     local rebirths = Instance.new("NumberValue", leaderstats) -- Creates a NumberValue
  93.     rebirths.Name = "Rebirths" -- Renames the NumberValue to "Rebirths"
  94. end
  95. usefulModule.AddCurrency = function(currency, increase) -- Creates a function called "AddCurrency"
  96.     currency.Value += increase -- Increases the currency sent trough the function by the number sent trough the function as well
  97. end
  98. usefulModule.SubtractCurrency = function(currency, decrease) -- Creates a function called "SubtractCurrency"
  99.     currency.Value -= decrease -- Decreases the currency sent trough the function by the number sent trough the function as well
  100. end
  101. usefulModule.DayNightCycle = function(daySpeed) -- Creates a function called "DayNightCycle"
  102.     task.spawn(function() -- Makes it so the function doesn't affect the rest of the code
  103.         while wait(daySpeed) do -- Creates a loop
  104.             game:GetService("Lighting").ClockTime += 0.05 -- Adds 0.05 to the ClockTime
  105.         end
  106.     end)
  107. end
  108. usefulModule.Format = function(value) -- Creates a function called "Format"
  109.     for i = 1, #suffixes do -- Loops trough all the suffixes
  110.         if tonumber(value) < 10 ^ (i * 3) then -- checks if the value sent trough the function is smaller than 10 ^ (i * 3)
  111.             return math.floor(value/((10^((i-1)*3))/100))/(100)..suffixes[i] -- Returns the obtained value
  112.         end
  113.     end
  114. end
  115. usefulModule.Comma = function(amount) -- Creates a function called "Comma"
  116.     if (math.abs(amount) < 1000) then  -- Checks if the amount is smaller than 1000
  117.         return tostring(amount) -- if it is, we will just return the amount
  118.     end
  119.     local str = (amount < 0 and "-" or "") .. tostring(math.abs(math.floor(amount))):reverse():gsub("%d%d%d","%1,"):gsub(",$",""):reverse() -- Adds a "-" or "" between each milestone (K,M,B,T, Qd,etc...)
  120.     if (not (amount == math.floor(amount))) then -- If the amount isn't the amount then
  121.         str = str .. "." .. (tostring(amount):match("%d+.$")) -- Makes the string have a dot
  122.     end
  123.     return str -- Returns the string obtained
  124. end
  125. usefulModule.AdvancedDamagingSystem = function(hit, character, emptyTable, damage) -- Creates a function called "AdvancedDamageSystem"
  126.     if hit.Parent.Name == character.Name then return end  -- Checks if the hit isn't the player himself
  127.     if hit then -- If there was a hit then...
  128.         if hit.Parent:FindFirstChild("Humanoid") then -- If the hit is a humanoid then...
  129.             if table.find(emptyTable, hit.Parent) then return -- if the humanoid is already in the table then...
  130.             else -- Checks the opposite
  131.                 hit.Parent:WaitForChild("Humanoid"):TakeDamage(damage) -- Damages the humanoid
  132.                 table.insert(emptyTable, hit.Parent) -- Puts the humanoid inside the table
  133.             end
  134.         end
  135.     end
  136. end
  137. usefulModule.TeleportPlayer = function(player, goalCFrame) -- Creates a function called "TeleportPlayer"
  138.     local character = player.Character -- Definds the player's character
  139.     local humanoidRootPart = character:WaitForChild("HumanoidRootPart") -- Definds the player's humanoidRootPart
  140.     humanoidRootPart.CFrame = goalCFrame -- Makes the player's humanoidRootPart CFrame to the CFrame given to the function
  141. end
  142. usefulModule.PetFollow = function(player, pet, position) -- Creates a function called "PetFollow"
  143.     if player then -- Checks if the player exists
  144.         local character = player.Character -- Gets the player's character
  145.         if character then -- If the player's character exists (or isn't = nil) then...
  146.             local humanoidRootPart = character.HumanoidRootPart -- Gets the player's humanoidRootPart
  147.             local newPet = pet:Clone() -- Gets the newPet
  148.             newPet.Parent = character -- Parents the newPet to the player's character
  149.             local bodyPos = Instance.new("BodyPosition", newPet) -- Creates a BodyPosition
  150.             bodyPos.MaxForce = Vector3.new(math.huge, math.huge, math.huge) -- Sets the BodyPosition's MaxForce to math.huge (Very big number)
  151.             local bodyGyro = Instance.new("BodyGyro", newPet) -- Creates a BodyGyro
  152.             bodyGyro.MaxTorque = Vector3.new(math.huge, math.huge, math.huge) -- Sets the MaxTorque of the BodyGyro the math.huge
  153.             while wait() do -- Creates a loop
  154.                 bodyPos.Position = humanoidRootPart.Position + position -- Constantly sets the pet's position to the player's position with an offset
  155.                 bodyGyro.CFrame = humanoidRootPart.CFrame -- Same here
  156.             end
  157.         end
  158.     end
  159. end
  160. usefulModule.PrintInstanceCount = function() -- Creates a function called "PrintInstanceCount"
  161.     local instanceCount = #workspace:GetDescendants() -- Gets all the stuff inside the workspace
  162.     print(instanceCount.." Objects") -- Prints the instance name and concatinates " Objects"
  163. end
  164. usefulModule.CountTo = function(from, to, increment) -- Creates a function called "CountTo"
  165.     for count = from, to, increment do -- Creates a loop
  166.         if count == to then -- If the count is done counting then...
  167.             print("Done!") -- Prints "Done!" inside the Output Window
  168.         end
  169.         if count ~= to then -- If the count is not done counting then...
  170.             print(count) -- Prints the count
  171.             wait(increment) -- Creates a cooldown
  172.         end
  173.     end
  174. end
  175. usefulModule.ClearAllTerrain = function() -- Creates a function called "ClearAllTerrain"
  176.     workspace.Terrain:Clear() -- Clears the terrain entirely
  177. end
  178. usefulModule.PrintObjectMass = function(object) -- Creates a function called "PrintObjectMass"
  179.     local objectMass = object:GetMass() -- Gets the mass of the object sent trough the function
  180.     print("The mass of "..object.Name.. " is "..objectMass) -- Prints the mass of the object
  181. end
  182. usefulModule.Rebirth = function(rebirths, statsToReset) -- Creates a function called "Rebirth"
  183.     rebirths.Value += 1 -- Increases the Rebirths value by 1
  184.     for index, statToReset in pairs(statsToReset) do -- Gets all the stats to reset inside the statstoreset table
  185.         statToReset.Value = 0 -- Resets the value of the stats to reset
  186.     end
  187. end
  188. usefulModule.ConvertCurrencyToSize = function(currency, sizeRate) -- Creates a function called "ConvertCurrencyToSize"
  189.     local player = game.Players:GetChildren() -- Gets all the players
  190.     for i = 1, #player do -- Loops trough all the players
  191.         if player[i].Character ~= nil then -- If the player's character isn't nil then...
  192.             local hum = player[i].Character.Humanoid -- Gets the character's humanoid
  193.             hum.HeadScale.Value = player[i].currency.Value / sizeRate + 1 -- Changes the Head size with the sizeCurrency
  194.             hum.BodyHeightScale.Value = player[i].currency.Value/sizeRate + 1 -- Changes the BodyHeightScale with the sizeCurrency
  195.             hum.BodyWidthScale.Value = player[i].currency.Value / sizeRate + 1 -- Changes the BodyWidthScale with the sizeCurrency
  196.             hum.BodyDepthScale.Value = player[i].currency.Value/sizeRate + 1 -- Changes the BodyDepthScale with the sizeCurrency
  197.             hum.WalkSpeed = player[i].currency.Value / sizeRate -- Changes the WalkSpeed with the sizeCurrency
  198.             hum.JumpPower = player[i].currency.Value / sizeRate -- Changes the JumpPower with the sizeCurrency
  199.             hum.MaxHealth = player[i].currency.Value + sizeRate -- Changes the MaxHealth with the sizeCurrency
  200.         end
  201.     end
  202. end
  203. usefulModule.PrintAll = function() -- Creates a function called "PrintAll"
  204.     for index, instance in pairs(workspace:GetDescendants()) do -- Gets all the objects in the Workspace
  205.         print(instance.Name) -- Prints the object name
  206.     end
  207. end
  208. return usefulModule -- Makes the module callable from all scripts
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement