Advertisement
1m1m0

Blackhole v4.42 (No Model Support)

Jan 1st, 2024 (edited)
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.19 KB | Source Code | 0 0
  1. -- MAIN BLACKHOLE v4.42 SCRIPT (No Model Attraction Support) --
  2.  
  3. local hole = script.Parent       -- More Information in [- CONTEXT -]
  4. local gravitationalConstantValue = hole.Configurations:FindFirstChild("GravitationalConstant")
  5. local eventHorizonDistanceValue  = hole.Configurations:FindFirstChild("EventHorizonDistance")
  6. local proportionalGravityValue   = hole.Configurations:FindFirstChild("ProportionalGravity")
  7. local sizeIncreaseFactorValue    = hole.Configurations:FindFirstChild("SizeIncreaseFactor")
  8. local adjustEventHorizonValue    = hole.Configurations:FindFirstChild("AdjustEventHorizon")
  9. local isAbsorptionEnabledValue   = hole.Configurations:FindFirstChild("IsAbsorptionEnabled")
  10. local killPlayersValue           = hole.Configurations:FindFirstChild("KillPlayers")
  11. local weldRemovalZoneSizeValue   = hole.Configurations:FindFirstChild("WeldRemovalZoneSize")
  12. local transparencyStepsValue     = hole.Configurations:FindFirstChild("TransparencySteps")
  13. local waitIntervalValue          = hole.Configurations:FindFirstChild("WaitInterval")
  14. local materialValue              = hole.Configurations:FindFirstChild("MaterialValue")
  15.  
  16. local absorbedParts = {} -- Store absorbed parts
  17.  
  18. local function ApplyGravity(object)
  19.     local direction = hole.Position - object.Position
  20.     local distance = direction.Magnitude
  21.     local forceMagnitude
  22.  
  23.     local gravitationalConstant = gravitationalConstantValue and gravitationalConstantValue.Value or 1000
  24.  
  25.     if proportionalGravityValue and proportionalGravityValue.Value then
  26.         forceMagnitude = (gravitationalConstant * hole.Size.X * object.Size.X) / (distance * distance)
  27.     else
  28.         forceMagnitude = gravitationalConstant -- Use custom gravitational constant
  29.     end
  30.  
  31.     local force = direction.Unit * forceMagnitude
  32.  
  33.     object.Velocity = object.Velocity + force
  34. end
  35.  
  36. local function CheckAndApplyGravity(obj)
  37.     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
  38.         return
  39.     end -- Add more classnames if targeted if not all objects are pulled
  40.  
  41.     if obj == hole then
  42.         return -- Excludes the black hole itself from gravitational pull
  43.     end
  44.  
  45.     if obj:IsA("Player") and (killPlayersValue and killPlayersValue.Value) then
  46.         return -- Exclude players from being affected by the black hole if killing players is enabled
  47.     end
  48.  
  49.     if obj.Anchored then
  50.         return -- Prevents black hole from applying gravity to anchored objects
  51.     end
  52.  
  53.     local distanceToHole = (hole.Position - obj.Position).Magnitude
  54.     local eventHorizonDistance = eventHorizonDistanceValue and eventHorizonDistanceValue.Value or hole.Size.X / 5
  55.  
  56.     if distanceToHole < eventHorizonDistance then
  57.         return -- Exclude objects within the event horizon from gravitational pull
  58.     end
  59.  
  60.     ApplyGravity(obj)
  61.  
  62.     -- Check if the object is within the weld removal zone
  63.     local weldRemovalZoneSize = weldRemovalZoneSizeValue and weldRemovalZoneSizeValue.Value or hole.Size.X * 4
  64.     local distanceToWeldRemovalZone = (hole.Position - obj.Position).Magnitude
  65.  
  66.     if distanceToWeldRemovalZone < weldRemovalZoneSize then
  67.         obj:BreakJoints() -- Break joints for objects within the weld removal zone
  68.     end
  69. end
  70.  
  71. local function onTouched(part)
  72.     local isAbsorptionEnabled = isAbsorptionEnabledValue and isAbsorptionEnabledValue.Value or false
  73.  
  74.     if not isAbsorptionEnabled then
  75.         return
  76.     end
  77.  
  78.     if part.Anchored then
  79.         return -- Excludes anchored objects from deletion
  80.     end
  81.  
  82.     -- Check if the part has already been absorbed
  83.     if absorbedParts[part] then
  84.         return
  85.     end
  86.  
  87.     absorbedParts[part] = true -- Mark the part as absorbed
  88.  
  89.     local colorValue = hole.Configurations:FindFirstChild("ColorValue")
  90.     local brickColor = colorValue and colorValue.Value or BrickColor.new(0)
  91.  
  92.     part.brickColor = brickColor -- Color it changes into before getting deleted
  93.  
  94.     local material = materialValue and materialValue.Value or Enum.Material.Neon
  95.     part.Material = material -- Material it changes into before getting deleted
  96.  
  97.     part.Anchored = true
  98.     part.CanCollide = false
  99.  
  100.     local transparencySteps = transparencyStepsValue and transparencyStepsValue.Value or "0.25,0.5,0.75"
  101.     local steps = {}
  102.     for step in transparencySteps:gmatch("([^,]+)") do
  103.         table.insert(steps, tonumber(step))
  104.     end
  105.  
  106.     local waitInterval = waitIntervalValue and waitIntervalValue.Value or 0.01
  107.  
  108.     for _, transparency in ipairs(steps) do
  109.         part.Transparency = transparency
  110.         wait(waitInterval) -- How long the fading will last (In seconds) on each transparency increment
  111.     end
  112.  
  113.     part:Destroy() -- Delete the part after the fading effect
  114.  
  115.     -- Increase the blackhole's size after consuming an object
  116.     local sizeIncreaseFactor = sizeIncreaseFactorValue and sizeIncreaseFactorValue.Value or 0.01
  117.     hole.Size = hole.Size + Vector3.new(sizeIncreaseFactor, sizeIncreaseFactor, sizeIncreaseFactor)
  118.  
  119.     -- Adjust event horizon if toggled
  120.     local adjustEventHorizon = adjustEventHorizonValue and adjustEventHorizonValue.Value or false
  121.  
  122.     if adjustEventHorizon then
  123.         eventHorizonDistanceValue.Value = hole.Size.X
  124.     end
  125. end
  126.  
  127. local connection = hole.Touched:Connect(onTouched)
  128.  
  129. game:GetService("RunService").Heartbeat:Connect(function()
  130.     for _, object in pairs(game.Workspace:GetDescendants()) do
  131.         CheckAndApplyGravity(object)
  132.     end
  133. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement