I am trying to make a bunch of rope constraints connect a bunch of links to form soccer net physics. I am achieving minor success, but it is generating wrong. There are no errors in the console.
Script:
local NetRows = script.Parent.Nets:GetChildren()
for i = 1, #NetRows do
local Row = NetRows[i]
for o = 1, #Row:GetChildren() do
if o <= #Row:GetChildren() - 1 then
local Link = Row[o]
local NextLink = Row[o + 1]
local Rope = Instance.new("RopeConstraint", Link)
local A0 = Instance.new("Attachment", Link)
local A1 = Instance.new("Attachment", NextLink)
Rope.Attachment0 = A0
Rope.Attachment1 = A1
Rope.Visible = true
Rope.Color = BrickColor.White()
local Length = (Link.Position - NextLink.Position).Magnitude
Rope.Length = Length
Rope.Thickness = .25
end
end
end
for i = 1, #NetRows do
local Row = NetRows[i]
for o = 1, #Row:GetChildren() do
if o <= #Row:GetChildren() - 1 and i <= #NetRows - 1 then
local Link = Row[o]
local NextLink = NetRows[i + 1]:FindFirstChild(o)
print(Link, NextLink, Row, NetRows[i + 1])
local Rope = Instance.new("RopeConstraint", Link)
local A0 = Instance.new("Attachment", Link)
local A1 = Instance.new("Attachment", NextLink)
Rope.Attachment0 = A0
Rope.Attachment1 = A1
Rope.Visible = true
Rope.Color = BrickColor.White()
local Length = (Link.Position - NextLink.Position).Magnitude
Rope.Length = Length
Rope.Thickness = .25
end
end
end
Why generate it? You can make it in Studio.
The issue you may have is that that many Constraints in such a small area could cause some lag issues.
Here’s a similar post about basketball nets: Why do rods swing?
Remove the first condition from the second if statement.
local NetRows = game.Workspace.Net:GetChildren()
for i = 1, #NetRows do
local Row = NetRows[i]
for o = 1, #Row:GetChildren() do
if o <= #Row:GetChildren() - 1 then
local Link = Row[o]
local NextLink = Row[o + 1]
local Rope = Instance.new("RopeConstraint", Link)
local A0 = Instance.new("Attachment", Link)
local A1 = Instance.new("Attachment", NextLink)
Rope.Attachment0 = A0
Rope.Attachment1 = A1
Rope.Visible = true
Rope.Color = BrickColor.White()
local Length = (Link.Position - NextLink.Position).Magnitude
Rope.Length = Length
Rope.Thickness = .25
end
end
end
for i = 1, #NetRows do
local Row = NetRows[i]
for o = 1, #Row:GetChildren() do
if i <= #NetRows - 1 then
local Link = Row[o]
local NextLink = NetRows[i + 1]:FindFirstChild(o)
print(Link, NextLink, Row, NetRows[i + 1])
local Rope = Instance.new("RopeConstraint", Link)
local A0 = Instance.new("Attachment", Link)
local A1 = Instance.new("Attachment", NextLink)
Rope.Attachment0 = A0
Rope.Attachment1 = A1
Rope.Visible = true
Rope.Color = BrickColor.White()
local Length = (Link.Position - NextLink.Position).Magnitude
Rope.Length = Length
Rope.Thickness = .25
end
end
end
What you can do is create the goal frame and net script in Studio, then while in test mode delete the script and save the whole goal as a Model.
Then you can go back into Edit mode and load the complete model into the game.
Also, instead of changing the Color of each individual RopeConstraint you can just select all the ropes and change the Color (or other properties like the Thickness) at the same time.