I made a black hole and have this script which sucks the player into the center once it touches this part, Thought I think it would be more realistic if it pulls more and more the closer you go to the black hole.
So just a small noticeable pull really far and when you’re closer it eventually pulls you in completely
function onTouched(hit)
bp = Instance.new("BodyPosition")
bp.Parent = hit
bp.maxForce = Vector3.new(4e+009, 4e+009, 4e+009)
bp.position = script.Parent.Position
end
connection = script.Parent.Touched:connect(onTouched)
Tweening is probably easiest, however for your script, you could get the distance away the player is, then times the values in the BodyPosition for the max force by 1/distance (so that it is more intense closer)
local MaxDistance = 1000
local Force = 10000
local CutoffDistance = 30
script.Parent.Touched:Connect(function(hit)
local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
if not Player then return end
local Character = hit.Parent
local Root = Character:FindFirstChild("HumanoidRootPart")
if not Root then return end
if Root:FindFirstChild("BlackholeForce") ~= nil then return end
local Distance = math.clamp((Root.Position - script.Parent.Position).Magnitude, 0, MaxDistance)
local BlackholeForce = Instance.new("BodyPosition")
BlackholeForce.Name = "BlackholeForce"
BlackholeForce.maxForce = Vector3.new(1, 1, 1) * (((MaxDistance-Distance)/MaxDistance) * Force)
BlackholeForce.Position = script.Parent.Position
BlackholeForce.Parent = Root
repeat
Distance = math.clamp((Root.Position - script.Parent.Position).Magnitude, 0, MaxDistance)
BlackholeForce.maxForce = Vector3.new(1, 1, 1) * (((MaxDistance-Distance)/MaxDistance) * Force)
wait()
until
Distance < CutoffDistance or Distance > MaxDistance or not Root
BlackholeForce:Destroy()
end)