Advertisement
1m1m0

Blackhole 4.31 (No Universal Configs)

Oct 16th, 2023 (edited)
121
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.83 KB | Source Code | 0 0
  1. -- MAIN BLACKHOLE v4.31 SCRIPT (All-in-One) --
  2. -- Barebones:
  3.  
  4. local hole = script.Parent
  5.  
  6. -- BLACKHOLE CLASSING --
  7.  
  8. -- Choose a Blackhole Class Preset (Set one of them to true!)
  9. local subStellarPreset = true   -- Sub-stellar preset (3x weaker than default). Perfect for satisfying simulations
  10. local stellarPreset = false    -- Stellar preset (Default). Somewhat accurate simulations
  11. local supermassivePreset = false -- Supermassive preset (3x stronger than default). Intense simulations (Requires a beefy computer)
  12.  
  13. -- Sub-Stellar Preset Settings
  14. local subStellarGravitationalConstant = 333
  15. local subStellarEventHorizonDistance = hole.Size.X / 15
  16. local subStellarSizeIncreaseFactor = 0.003
  17. local subStellarProportionalGravity = true
  18. local subStellarAdjustEventHorizon = false
  19. local subStellarIsAbsorptionEnabled = true
  20. local subStellarKillPlayers = true
  21. local subStellarWeldRemovalZoneSize = hole.Size.X * 2
  22.  
  23. -- Stellar (Default) Preset Settings
  24. local stellarGravitationalConstant = 1000
  25. local stellarEventHorizonDistance = hole.Size.X / 5
  26. local stellarSizeIncreaseFactor = 0.01
  27. local stellarProportionalGravity = true
  28. local stellarAdjustEventHorizon = false
  29. local stellarIsAbsorptionEnabled = true
  30. local stellarKillPlayers = true
  31. local stellarWeldRemovalZoneSize = hole.Size.X * 4
  32.  
  33. -- Supermassive Preset Settings
  34. local supermassiveGravitationalConstant = 3000
  35. local supermassiveEventHorizonDistance = hole.Size.X / 2
  36. local supermassiveSizeIncreaseFactor = 0.03
  37. local supermassiveProportionalGravity = true
  38. local supermassiveAdjustEventHorizon = false
  39. local supermassiveIsAbsorptionEnabled = true
  40. local supermassiveKillPlayers = true
  41. local supermassiveWeldRemovalZoneSize = hole.Size.X * 6
  42.  
  43. local absorbedParts = {} -- Store absorbed parts
  44.  
  45. -- Determine the class preset based on the chosen presets
  46. local presetValues = {
  47.     subStellarPreset,
  48.     stellarPreset,
  49.     supermassivePreset,
  50. }
  51.  
  52. local numTruePresets = 0
  53. local chosenPresetIndex = 2 -- Default to Stellar
  54.  
  55. for i, isPresetTrue in ipairs(presetValues) do
  56.     if isPresetTrue then
  57.         numTruePresets = numTruePresets + 1
  58.         chosenPresetIndex = i
  59.     end
  60. end
  61.  
  62. if numTruePresets > 1 then
  63.     -- More than one preset is set to true, choose the lowest classing (Sub-Stellar)
  64.     chosenPresetIndex = 1
  65. elseif numTruePresets == 0 then
  66.     -- None are set to true, choose the default (Stellar)
  67.     chosenPresetIndex = 2
  68. end
  69.  
  70. -- Set the preset values based on the chosen class preset
  71. subStellarPreset = chosenPresetIndex == 1
  72. stellarPreset = chosenPresetIndex == 2
  73. supermassivePreset = chosenPresetIndex == 3
  74.  
  75. -- Initialize the global variables
  76. local gravitationalConstant
  77. local eventHorizonDistance
  78. local sizeIncreaseFactor
  79. local proportionalGravity
  80. local adjustEventHorizon
  81. local isAbsorptionEnabled
  82. local killPlayers
  83. local weldRemovalZoneSize
  84.  
  85. -- Functions for setting variables based on preset
  86. local function SetSubStellarPreset()
  87.     gravitationalConstant = subStellarGravitationalConstant
  88.     eventHorizonDistance = subStellarEventHorizonDistance
  89.     sizeIncreaseFactor = subStellarSizeIncreaseFactor
  90.     proportionalGravity = subStellarProportionalGravity
  91.     adjustEventHorizon = subStellarAdjustEventHorizon
  92.     isAbsorptionEnabled = subStellarIsAbsorptionEnabled
  93.     killPlayers = subStellarKillPlayers
  94.     weldRemovalZoneSize = subStellarWeldRemovalZoneSize
  95. end
  96.  
  97. local function SetStellarPreset()
  98.     gravitationalConstant = stellarGravitationalConstant
  99.     eventHorizonDistance = stellarEventHorizonDistance
  100.     sizeIncreaseFactor = stellarSizeIncreaseFactor
  101.     proportionalGravity = stellarProportionalGravity
  102.     adjustEventHorizon = stellarAdjustEventHorizon
  103.     isAbsorptionEnabled = stellarIsAbsorptionEnabled
  104.     killPlayers = stellarKillPlayers
  105.     weldRemovalZoneSize = stellarWeldRemovalZoneSize
  106. end
  107.  
  108. local function SetSupermassivePreset()
  109.     gravitationalConstant = supermassiveGravitationalConstant
  110.     eventHorizonDistance = supermassiveEventHorizonDistance
  111.     sizeIncreaseFactor = supermassiveSizeIncreaseFactor
  112.     proportionalGravity = supermassiveProportionalGravity
  113.     adjustEventHorizon = supermassiveAdjustEventHorizon
  114.     isAbsorptionEnabled = supermassiveIsAbsorptionEnabled
  115.     killPlayers = supermassiveKillPlayers
  116.     weldRemovalZoneSize = supermassiveWeldRemovalZoneSize
  117. end
  118.  
  119. -- Set the variables based on the chosen class preset
  120. if subStellarPreset then
  121.     SetSubStellarPreset()
  122. elseif stellarPreset then
  123.     SetStellarPreset()
  124. elseif supermassivePreset then
  125.     SetSupermassivePreset()
  126. end
  127.  
  128. function ApplyGravity(object)
  129.     local direction = hole.Position - object.Position
  130.     local distance = direction.Magnitude
  131.     local forceMagnitude
  132.  
  133.     if proportionalGravity then
  134.         forceMagnitude = (gravitationalConstant * hole.Size.X * object.Size.X) / (distance * distance)
  135.     else
  136.         forceMagnitude = gravitationalConstant
  137.     end
  138.  
  139.     local force = direction.Unit * forceMagnitude
  140.  
  141.     object.Velocity = object.Velocity + force
  142. end
  143.  
  144. local function CheckAndApplyGravity(obj)
  145.     if not obj:IsA("BasePart") or obj:IsA("Model") or obj:IsA("Union") or obj:IsA("Tool") or obj:IsA("MeshPart") or obj:IsA("Mesh") then
  146.         return
  147.     end
  148.  
  149.     if obj == hole then
  150.         return
  151.     end
  152.  
  153.     if obj:IsA("Player") and not killPlayers then
  154.         return
  155.     end
  156.  
  157.     if obj.Anchored then
  158.         return
  159.     end
  160.  
  161.     local distanceToHole = (hole.Position - obj.Position).Magnitude
  162.     if distanceToHole < eventHorizonDistance then
  163.         return
  164.     end
  165.  
  166.     ApplyGravity(obj)
  167.  
  168.     local distanceToWeldRemovalZone = (hole.Position - obj.Position).Magnitude
  169.     if distanceToWeldRemovalZone < weldRemovalZoneSize then
  170.         obj:BreakJoints()
  171.     end
  172. end
  173.  
  174. game:GetService("RunService").Heartbeat:Connect(function()
  175.     for _, object in pairs(game.Workspace:GetDescendants()) do
  176.         CheckAndApplyGravity(object)
  177.     end
  178. end)
  179.  
  180. function onTouch(part)
  181.     local humanoid = part.Parent:FindFirstChild("Humanoid")
  182.     if humanoid then
  183.         humanoid.Health = 0
  184.     end
  185.  
  186.     part.CanCollide = true
  187. end
  188.  
  189. function onTouched(part)
  190.     if not isAbsorptionEnabled then
  191.         return
  192.     end
  193.  
  194.     if part.Anchored then
  195.         return
  196.     end
  197.  
  198.     if absorbedParts[part] then
  199.         return
  200.     end
  201.  
  202.     absorbedParts[part] = true
  203.  
  204.     part.BrickColor = BrickColor.new(0)
  205.     part.Material = Enum.Material.Neon
  206.     part.Anchored = false
  207.  
  208.     local transparencySteps = {0.25, 0.5, 0.75}
  209.     for _, transparency in ipairs(transparencySteps) do
  210.         part.Transparency = transparency
  211.         wait(0.01)
  212.     end
  213.  
  214.     part:Destroy()
  215.  
  216.     hole.Size = hole.Size + Vector3.new(sizeIncreaseFactor, sizeIncreaseFactor, sizeIncreaseFactor)
  217.  
  218.     if adjustEventHorizon then
  219.         eventHorizonDistance = hole.Size.X
  220.     end
  221. end
  222.  
  223. local connection = hole.Touched:Connect(onTouched)
  224.  
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement