-
I’m not very verse in scripting but I’m currently trying to create a script that makes a RopeConstraint between players. The idea is that when two or more players join a server, a RopeConstraint is automatically created between them.
-
As of now I have script that creates and an attachment within the HumanoidRootPart of every player that joins, and that also creates a RopeConstraint inside the Workspace. My issue is that whenever I run the script, the Attachment values, Attachment0 and Attachment1 don’t actually connect to the RopeContraint and Attachment within the players HumanoidRootPart. Aka ( No Rope is created)
-
I’ve been tweaking the script often to see what works but I always come to the same issue with the attachment values. I’ve also tried using the RootAttachment instead to see if that may fix it, but no invail.
-
Note: I had been given a lot of help in making this script from a close friend of mine who knows much more about Lua than I do. Unfortunately He isn’t going to be available to help me for quite a bit, as to why I’m making this post.
^^^ This is the Idea. I did this manually in the studio not by the script.
local ropeThickness = 0.2
local function InsertAttachment(player)
local character = player.Character or player.CharacterAdded:Wait()
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
local attachment = humanoidRootPart:FindFirstChild("Attachment")
if not attachment then
attachment = Instance.new("Attachment")
attachment.Name = "Attachment"
attachment.Position = Vector3.new(0, 0, 0)
attachment.Parent = humanoidRootPart
end
print("Attachment inserted for player: " .. player.Name)
end
local function InsertRopeConstraint()
local players = game.Players:GetPlayers()
local attachments = {}
for _, player in ipairs(players) do
InsertAttachment(player)
table.insert(attachments, player.Character.HumanoidRootPart.Attachment)
end
local ropeConstraint = Instance.new("RopeConstraint")
ropeConstraint.Name = "RopeConstraint"
ropeConstraint.Visible = true
ropeConstraint.Parent = workspace
ropeConstraint.Length = ropeLength
ropeConstraint.Thickness = ropeThickness
for _, attachment in ipairs(attachments) do
ropeConstraint.Attachment0 = attachment
ropeConstraint.Attachment1 = workspace.RopeConstraint.Attachment1
ropeConstraint:Clone().Parent = workspace
end
print("Rope constraint inserted and connected to player attachments")
end
local function OnPlayerAdded(player)
player.CharacterAdded:Connect(function()
InsertAttachment(player)
end)
end
for _, player in ipairs(game.Players:GetPlayers()) do
OnPlayerAdded(player)
end
game.Players.PlayerAdded:Connect(OnPlayerAdded)
InsertRopeConstraint()```