I used the way exactly like what they did in this post.
And I am facing the same problem. No matter how I try, it keeps disappear in a short time.
Is there a different way?
Here’s my script:
local TimeScale = game.Workspace.Stats.TimeScale.Value
local G = 6.67*10^-11
local Service = game:GetService(“RunService”)
local Childrens = game.Workspace:GetChildren()
for i = 1,#Childrens do
if Childrens[i].Name == “Planet” then
local BodyForce = Instance.new(“BodyForce”,script.Parent)
local TargetObject = Instance.new(“ObjectValue”,BodyForce)
TargetObject.Name = “Target”
TargetObject.Value = Childrens[i]
BodyForce.Parent = script.Parent
end
end
Service.Stepped:Connect(function()
local BodyMovers = script.Parent:GetChildren()
for i = 1,#BodyMovers do
if BodyMovers[i].ClassName == “BodyForce” then
local Target = BodyMovers[i].Target.Value
local r = script.Parent.Position - Target.Position
local F = G*script.Parent:GetMass()*Target:GetMass()/r.Magnitude^2
BodyMovers[i].Force =F*r.Unit
end
end
end)
Please reply, I can’t stay here for a day.