Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local blackHole = script.Parent -- Change this to reference your black hole part
- local gravitationalConstant = 1000 -- Adjust this value to control the strength of the attraction
- local function ApplyGravity(object)
- local direction = blackHole.Position - object.Position
- local distance = direction.Magnitude
- local forceMagnitude = (gravitationalConstant * blackHole.Size.X * object.Size.X) / (distance * distance)
- local force = direction.Unit * forceMagnitude
- object.Velocity = object.Velocity + force
- end
- game:GetService("RunService").Heartbeat:Connect(function()
- for _, object in pairs(game.Workspace:GetChildren()) do
- if object:IsA("Part") and object ~= blackHole then
- ApplyGravity(object)
- end
- end
- end)
Advertisement
Advertisement