Just after reading your post, I went to Roblox Studio to experiment with physics constraints. I don’t know anything about most of the constraints. But I still added a hinge and a line force in two parts. I started experimenting with them. And I made something cool that comes back when moved away.
So, since I’m learning to script, I wanted to make the same thing with scripts. And then I started making an instance for all of them. But since Roblox connects the constraints automatically, and I didn’t know I had to connect the attachments, I asked ChatGPT for help. It helped me and connected my attachments. Then I saw it worked. But then I noticed that the thing I made actually swings forever. As of right now, it’s still swinging in my Roblox Studio lol. Here’s a demo:
And the script I made:
--Holder--
local holder = Instance.new("Part")
holder.Name = "Holder"
holder.Parent = game.Workspace
holder.Color = Color3.fromRGB(52, 52, 52)
holder.Material = Enum.Material.SmoothPlastic
holder.Position = Vector3.new(0, 10, 0)
holder.Anchored = true
--Ball--
local ball = Instance.new("Part")
ball.Name = "Ball"
ball.Parent = game.Workspace
ball.Color = Color3.fromRGB(255, 0, 0)
ball.Material = Enum.Material.SmoothPlastic
ball.Position = Vector3.new(0, 5, 0)
ball.Anchored = false
ball.Shape = Enum.PartType.Ball
--Attachments--
local hat0 = Instance.new("Attachment")
hat0.Name = "hat0"
hat0.Parent = holder
hat0.Position = Vector3.new(0, 10, 0)
local hat1 = Instance.new("Attachment")
hat1.Name = "hat1"
hat1.Parent = ball
hat1.Position = Vector3.new(0, 5, 0)
local hinge = Instance.new("HingeConstraint")
hinge.Parent = holder
hinge.Attachment0 = hat0
hinge.Attachment1 = hat1
hinge.Position = hat1.Position
local lat0 = Instance.new("Attachment")
lat0.Name = "lat0"
lat0.Parent = holder
lat0.Position = Vector3.new(0, 10, 0)
local lat1 = Instance.new("Attachment")
lat1.Name = "lat1"
lat1.Parent = ball
lat1.Position = Vector3.new(0, 5, 0)
local lineForce = Instance.new("LineForce")
lineForce.Parent = holder
lineForce.Attachment0 = lat0
lineForce.Attachment1 = lat1
I mean you can’t expect great code from a beginner…
Update: It still didn’t stop, after a long time, but it did slow down. But when I touched it a little bit, it started moving fast again… I think you need one big part or something that moves all of the balls together when the ball slows down. But you should experiment yourself too…
Also, I’m interested in constraints a lot. If anyone has any tutorials/links to Roblox Guide, then please reply to me. I want to learn more about these constraints!