My Carry Script is creating errors but, I can't fix them. Is there anyway to fix this?
Asked by
4 years ago Edited 4 years ago
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:
01 | local PS = game:GetService( "PhysicsService" ) |
05 | function CarryModule:Carry(Plr, IsCarrying, FirstPly) |
06 | if not Carryed [ FirstPly ] then |
07 | print ( "Player:" ,Plr, " Carry Value:" ,IsCarrying, " Carrying:" ,FirstPly) |
08 | Carryed [ FirstPly ] = (Plr.Name.. "*" ..FirstPly) |
09 | print (Carryed [ FirstPly ] ) |
11 | PS:CreateCollisionGroup( "CarryPhysics" ) |
12 | PS:CollisionGroupSetCollidable( "CarryPhysics" , "CarryPhysics" , false ) |
14 | local Plr, FirstPly = FirstPly.Character.Head, Plr.Character.PrimaryPart |
15 | FirstPly.Character.Humanoid.PlatformStand = true |
17 | local W = Instance.new( "Weld" ) |
18 | W.Name = "__CARRYWELD" |
21 | W.C 1 = CFrame.new( 0 , 0 , 1.75 ) |
24 | for _,v in pairs (FirstPly.Character:GetChildren()) do |
25 | if v:IsA( "BasePart" ) then |
26 | PS:SetPartCollisionGroup(v, "CarryPhysics" ) |
31 | for _,v in pairs (Plr.Character:GetChildren()) do |
32 | if v:IsA( "BasePart" ) then |
33 | PS:SetPartCollisionGroup(v, "CarryPhysics" ) |
38 | print ( "Player: " ,FirstPly, " is already being carried." ) |
39 | print (Carryed [ FirstPly ] ) |
43 | function CarryModule:Drop(Plr, IsCarrying, FirstPly) |
44 | print ( "Player:" ,Plr, " Carry Value:" ,IsCarrying, " Dropped:" ,FirstPly) |
46 | FirstPly.Character.Humanoid.PlatformStand = false |
47 | if FirstPly.Character.PrimaryPart:FindFirstChild( "__CARRYWELD" ) then |
48 | FirstPly.Character.PrimaryPart.__CARRYWELD:Destroy() |
51 | for _,v in pairs (FirstPly.Character:GetChildren()) do |
52 | if v:IsA( "BasePart" ) then |
53 | v.CollisionGroupID = 0 |
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.