Advertisement
1m1m0

Blackhole 4.0 Original Source Code

Oct 16th, 2023 (edited)
112
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.77 KB | Source Code | 0 0
  1. local blackHole = script.Parent -- Change this to reference your black hole part
  2. local gravitationalConstant = 1000 -- Adjust this value to control the strength of the attraction
  3.  
  4. local function ApplyGravity(object)
  5.     local direction = blackHole.Position - object.Position
  6.     local distance = direction.Magnitude
  7.     local forceMagnitude = (gravitationalConstant * blackHole.Size.X * object.Size.X) / (distance * distance)
  8.     local force = direction.Unit * forceMagnitude
  9.    
  10.     object.Velocity = object.Velocity + force
  11. end
  12.  
  13. game:GetService("RunService").Heartbeat:Connect(function()
  14.     for _, object in pairs(game.Workspace:GetChildren()) do
  15.         if object:IsA("Part") and object ~= blackHole then
  16.             ApplyGravity(object)
  17.         end
  18.     end
  19. end)
  20.  
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement