Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- MAIN BLACKHOLE v4.42 SCRIPT (No Model Attraction Support) --
- local hole = script.Parent -- More Information in [- CONTEXT -]
- local gravitationalConstantValue = hole.Configurations:FindFirstChild("GravitationalConstant")
- local eventHorizonDistanceValue = hole.Configurations:FindFirstChild("EventHorizonDistance")
- local proportionalGravityValue = hole.Configurations:FindFirstChild("ProportionalGravity")
- local sizeIncreaseFactorValue = hole.Configurations:FindFirstChild("SizeIncreaseFactor")
- local adjustEventHorizonValue = hole.Configurations:FindFirstChild("AdjustEventHorizon")
- local isAbsorptionEnabledValue = hole.Configurations:FindFirstChild("IsAbsorptionEnabled")
- local killPlayersValue = hole.Configurations:FindFirstChild("KillPlayers")
- local weldRemovalZoneSizeValue = hole.Configurations:FindFirstChild("WeldRemovalZoneSize")
- local transparencyStepsValue = hole.Configurations:FindFirstChild("TransparencySteps")
- local waitIntervalValue = hole.Configurations:FindFirstChild("WaitInterval")
- local materialValue = hole.Configurations:FindFirstChild("MaterialValue")
- local absorbedParts = {} -- Store absorbed parts
- local function ApplyGravity(object)
- local direction = hole.Position - object.Position
- local distance = direction.Magnitude
- local forceMagnitude
- local gravitationalConstant = gravitationalConstantValue and gravitationalConstantValue.Value or 1000
- if proportionalGravityValue and proportionalGravityValue.Value then
- forceMagnitude = (gravitationalConstant * hole.Size.X * object.Size.X) / (distance * distance)
- else
- forceMagnitude = gravitationalConstant -- Use custom gravitational constant
- end
- local force = direction.Unit * forceMagnitude
- object.Velocity = object.Velocity + force
- end
- local function CheckAndApplyGravity(obj)
- 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
- return
- end -- Add more classnames if targeted if not all objects are pulled
- if obj == hole then
- return -- Excludes the black hole itself from gravitational pull
- end
- if obj:IsA("Player") and (killPlayersValue and killPlayersValue.Value) then
- return -- Exclude players from being affected by the black hole if killing players is enabled
- end
- if obj.Anchored then
- return -- Prevents black hole from applying gravity to anchored objects
- end
- local distanceToHole = (hole.Position - obj.Position).Magnitude
- local eventHorizonDistance = eventHorizonDistanceValue and eventHorizonDistanceValue.Value or hole.Size.X / 5
- if distanceToHole < eventHorizonDistance then
- return -- Exclude objects within the event horizon from gravitational pull
- end
- ApplyGravity(obj)
- -- Check if the object is within the weld removal zone
- local weldRemovalZoneSize = weldRemovalZoneSizeValue and weldRemovalZoneSizeValue.Value or hole.Size.X * 4
- local distanceToWeldRemovalZone = (hole.Position - obj.Position).Magnitude
- if distanceToWeldRemovalZone < weldRemovalZoneSize then
- obj:BreakJoints() -- Break joints for objects within the weld removal zone
- end
- end
- local function onTouched(part)
- local isAbsorptionEnabled = isAbsorptionEnabledValue and isAbsorptionEnabledValue.Value or false
- if not isAbsorptionEnabled then
- return
- end
- if part.Anchored then
- return -- Excludes anchored objects from deletion
- end
- -- Check if the part has already been absorbed
- if absorbedParts[part] then
- return
- end
- absorbedParts[part] = true -- Mark the part as absorbed
- local colorValue = hole.Configurations:FindFirstChild("ColorValue")
- local brickColor = colorValue and colorValue.Value or BrickColor.new(0)
- part.brickColor = brickColor -- Color it changes into before getting deleted
- local material = materialValue and materialValue.Value or Enum.Material.Neon
- part.Material = material -- Material it changes into before getting deleted
- part.Anchored = true
- part.CanCollide = false
- local transparencySteps = transparencyStepsValue and transparencyStepsValue.Value or "0.25,0.5,0.75"
- local steps = {}
- for step in transparencySteps:gmatch("([^,]+)") do
- table.insert(steps, tonumber(step))
- end
- local waitInterval = waitIntervalValue and waitIntervalValue.Value or 0.01
- for _, transparency in ipairs(steps) do
- part.Transparency = transparency
- wait(waitInterval) -- How long the fading will last (In seconds) on each transparency increment
- end
- part:Destroy() -- Delete the part after the fading effect
- -- Increase the blackhole's size after consuming an object
- local sizeIncreaseFactor = sizeIncreaseFactorValue and sizeIncreaseFactorValue.Value or 0.01
- hole.Size = hole.Size + Vector3.new(sizeIncreaseFactor, sizeIncreaseFactor, sizeIncreaseFactor)
- -- Adjust event horizon if toggled
- local adjustEventHorizon = adjustEventHorizonValue and adjustEventHorizonValue.Value or false
- if adjustEventHorizon then
- eventHorizonDistanceValue.Value = hole.Size.X
- end
- end
- local connection = hole.Touched:Connect(onTouched)
- game:GetService("RunService").Heartbeat:Connect(function()
- for _, object in pairs(game.Workspace:GetDescendants()) do
- CheckAndApplyGravity(object)
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement