Soccer Net Generation

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.

image

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
3 Likes

What do one of these links look like? A single white ball?

2 Likes

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?

1 Like

Yes, each link is a .5x.5x.5x white ball.

I am trying to generate it because I don’t want to have to connect each individual link and color each rope and all that.

Before:
image

After:
image

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
1 Like

It seems as if this should work, but when I tried it I got this:

Make sure your rows are in the right order, I noticed that you labeled your Links as 1,2 ,3, 4, 5, …, Do the same thing for your rows

I just checked, they are in the right order.

Try anchoring them to see if they generate correctly

image

Seems like they’re generating properly.

If you unanchor everything but the edge links it should be fine

1 Like

I just did that, and I realized that for some reason the top row’s links were connected to the third or fourth rows links.

Then it’s likely that your rows are out of order

1 Like

I just double checked, the top row is 1 and the bottom is 7. Each row in between is named properly as well?

Here is my roblox place with the soccer net setup:
export.rbxl (51.2 KB)

1 Like

I guess I’ll just use this model, as it’s working. Thanks for the help.

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.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.