#This script keeps giving me the same error and I dont know why

19 messages · Page 1 of 1 (latest)

indigo quartz
#

Whenever I try to use this script it gives me the error ServerScriptService.grabhandler:9: attempt to index nil with 'FindFirstChild' - Server - grabhandler:9

local repstore = game:GetService("ReplicatedStorage")
local message = repstore.grab

message.OnServerEvent:Connect(function(player)
    print("something happened")

    local char = player.Character
    local arm = char:FindFirstChild("RightArm")
    local armattach = arm:FindFirstChild("RightGripAttachment")
    local hrp = char:FindFirstChild("HumanoidRootPart")
    if not hrp then return end 

    local hitbox = Instance.new("Part")
    local weld = Instance.new("WeldConstraint")

    hitbox.Parent = game.Workspace
    hitbox.Massless = true
    hitbox.CanCollide = false
    hitbox.CastShadow = false
    hitbox.Transparency = 1
    hitbox.Size = Vector3.new(3, 3, 4) 

    
    local forwardOffset = 2 
    hitbox.CFrame = hrp.CFrame * CFrame.new(0, 0, -forwardOffset)

    weld.Parent = hitbox
    weld.Part0 = hitbox
    weld.Part1 = hrp
    
    hitbox.Touched:Connect(function(part)
        local humanoid = part.Parent:FindFirstChild("Humanoid")
        
        if humanoid then
            print("hum found")
        end
        
        local attachment = humanoid.Parent:FindFirstChild("Torso"):FindFirstChild("WaistBackAttachment")
        local weld = Instance.new("RigidConstraint")
        
        weld.Parent = attachment
        weld.Attachment0 = attachment
        weld.Attachment1 = armattach
        
        
    end)
    task.wait(1)
    hitbox:Destroy()
end)

#

everything else works It just cant find the attachment on line 9

frosty solstice
#

or your just finding a nonexistent attachment (just realized my question is stupid)

#

i dont know if this will help but instead of FindFirstChild maybe try WaitForChild

indigo quartz
frosty solstice
#

huh

indigo quartz
#

i dunno

#

r6 people have a right grip

#

wait

#

I think I found an issue

#

its not finding the arm

#

theres a space in right arm

#

🤦‍♂️

frosty solstice
indigo quartz
#

thats pretty funny

frosty solstice
#

so its solved now?

#

ts reminds me of when i didnt rtealize i was using a server script instead of a local script bru

indigo quartz