Attachment needs to be parented to basepart but it is

Hi, I’m making like a spider man rope thingy and I’m making an attachment from the part to the player. Whenever I set the attachments parent, it comes up with an error. I have no idea why it is causing it because the part IS a basepart.

Error is shown below:
image

Here is my current code:

--// Local Script in StarterGUI \\
local player = game.Players.LocalPlayer --Gets the player the script is running for.
local mouse = player:GetMouse() --Gets the player's mouse.

mouse.Move:Connect(function()
	local target = mouse.Target
	if not target then
		mouse.Icon = 'http://www.roblox.com/asset/?id=591711615'
	else
		if target:IsA("BasePart") or target:IsA("Model") then 
			if target == workspace.Base or target.Parent == workspace.Baseplate or target == workspace.SpawnLocation then 
				if target.Parent == workspace then
					mouse.Icon = 'http://www.roblox.com/asset/?id=6888146193'
					game.ReplicatedStorage.CreatePart:FireServer(player,target)
				else 
					mouse.Icon = 'http://www.roblox.com/asset/?id=6888146193'
				end
			else
				mouse.Icon = 'http://www.roblox.com/asset/?id=591711615' 
			end
		end
	end
end)


-- // Server Script in ServerScriptService \\
game.ReplicatedStorage.CreatePart.OnServerEvent:Connect(function(player, part)
	local Rope = Instance.new('SpringConstraint')
	local A0 = Instance.new('Attachment')
	local A1 = Instance.new('Attachment')
	A0.Parent = part --Error is on this line
	A1.Parent = player.Character.HumanoidRootPart
	Rope.Attachment0 = A0
	Rope.Attachment1 = A1
	Rope.Parent = player.Character
	Rope.Visible = true
	Rope.LimitsEnabled = true
	Rope.MaxLength = 14
	local BV = Instance.new('BodyVelocity')
	local char = player.Character
	char:WaitForChild("Humanoid"):GetPropertyChangedSignal("MoveDirection"):Connect(function()
		BV.Velocity = player.Character.Humanoid.MoveDirection * 26
		BV.MaxForce = Vector3.new(1000000,0,1000000)
	end)
	BV.Parent = char.HumanoidRootPart
end)

Can anyone help?

I’m not sure, but I believe this is could be because on this line of code, you wouldn’t need to fire the player, since the player parameter would already be automatically inserted.

1 Like