Hello, I am trying to achieve a carry system for carrying players like in Adopt Me, It's been going good good up until the weld part. I have never used welds so, I looked at some previous methods and tried but none of them seemed to work.
This is all the code, I have so far:
local PS = game:GetService("PhysicsService")
local CarryModule = {}
local Carryed = {}
function CarryModule:Carry(Plr, IsCarrying, FirstPly)
if not Carryed[FirstPly] then
print("Player:",Plr," Carry Value:",IsCarrying," Carrying:",FirstPly)
Carryed[FirstPly] = (Plr.Name.."*"..FirstPly)
print(Carryed[FirstPly])
PS:CreateCollisionGroup("CarryPhysics")
PS:CollisionGroupSetCollidable("CarryPhysics", "CarryPhysics", false)
local Plr, FirstPly = FirstPly.Character.Head, Plr.Character.PrimaryPart
FirstPly.Character.Humanoid.PlatformStand = true
local W = Instance.new("Weld")
W.Name = "__CARRYWELD"
W.Part0 = Plr
W.Part1 = FirstPly
W.C1 = CFrame.new(0, 0, 1.75)
W.Parent = FirstPly
for _,v in pairs(FirstPly.Character:GetChildren()) do
if v:IsA("BasePart") then
PS:SetPartCollisionGroup(v, "CarryPhysics")
v.Massless = true
end
end
for _,v in pairs(Plr.Character:GetChildren()) do
if v:IsA("BasePart") then
PS:SetPartCollisionGroup(v, "CarryPhysics")
end
end
else
print("Player: ",FirstPly," is already being carried.")
print(Carryed[FirstPly])
end
end
function CarryModule:Drop(Plr, IsCarrying, FirstPly)
print("Player:",Plr," Carry Value:",IsCarrying," Dropped:",FirstPly)
FirstPly.Character.Humanoid.PlatformStand = false
if FirstPly.Character.PrimaryPart:FindFirstChild("__CARRYWELD") then
FirstPly.Character.PrimaryPart.__CARRYWELD:Destroy()
end
for _,v in pairs(FirstPly.Character:GetChildren()) do
if v:IsA("BasePart") then
v.CollisionGroupID = 0
v.Maseless = false
end
end
end
return CarryModule
The errors seem to occur at line 15 and 48:
08:34:05.446 - ServerScriptService.CarryModuleScript:15: attempt to index nil with 'Head'
08:34:06.779 - ServerScriptService.CarryModuleScript:48: attempt to index nil with 'Humanoid'
If someone is able to help, I'd really appreciate it.

1 comment
On line 15, do you mean Plr and not FirstPly?