Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local celestial = script.Parent -- Change this to reference your black hole part
- local gravitationalConstant = 50 -- Adjust this value to control the strength of the attraction
- local function ApplyGravity(object)
- local direction = celestial.Position - object.Position
- local force = direction.Unit * gravitationalConstant
- local bodyForce = object:FindFirstChild("BlackHoleBodyForce")
- if not bodyForce then
- bodyForce = Instance.new("BodyForce")
- bodyForce.Name = "BlackHoleBodyForce"
- bodyForce.Force = force
- bodyForce.Parent = object
- else
- bodyForce.Force = force
- end
- end
- game:GetService("RunService").Heartbeat:Connect(function()
- for _, object in pairs(game.Workspace:GetChildren()) do
- if object:IsA("BasePart") and object ~= celestial then
- ApplyGravity(object)
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement