I made a tool event, where when you press E it sends an event to the server (Client to Server) and then it clones a tool and puts it in your backpack. For some reason I keep getting errors that say "Attempt to index nil with 'Parent'.

Here is the Server Script attempt


game.ReplicatedStorage.radEv.OnServerEvent:Connect(function(Player, var)
    var.Archivable = true
    local clo = var:Clone()
    Player.Character.Archivable = true
    Player.Archivable = true
    clo.Parent = Player:WaitForChild("Backpack")
end)

game.ReplicatedStorage.gasSt.OnServerEvent:Connect(function(Player, var2)
    var2.Archivable = true
    local clone = var2:Clone()
    Player.Character.Archivable = true
    Player.Archivable = true
    clone.Parent = Player:WaitForChild("Backpack")
end)

I then tried to make it work on the local script but the same error occured

llocal HumanoidRootPart = game:GetService("Players").LocalPlayer.Character:WaitForChild("HumanoidRootPart")
local UI = game:GetService("UserInputService")
local lockerNSI = workspace.nsiLocker.Part
local idNSI = workspace.nsiID.ID
local player = game:GetService("Players").LocalPlayer


UI.InputBegan:Connect(function(keyCode)
    if keyCode.keyCode == Enum.KeyCode.F then


        if (lockerNSI.Position - HumanoidRootPart.Position).magnitude < 10 then
            if player:IsInGroup(redacted) then
                local var = game:GetService("ReplicatedStorage"):FindFirstChild("P2")
                game.ReplicatedStorage.radEv:FireServer(var)
            end
        end
        if (idNSI.Position - HumanoidRootPart.Position).magnitude < 10 then
            if player:IsInGroup(redacted) then
                local var2 = game:GetService("ReplicatedStorage"):FindFirstChild("Badge")
                game.ReplicatedStorage.gasSt:FireServer(var2)
            end
        end
    end
end)


-- Made by Developermark99



Help would be appreciated.. thanks!

4 comments

0

When you press F*

0

What line is the error on?

0

Why are you making everything archivable? And what line is the error on? You can't just throw code at us and ask us to fix it. You have to give more information.

0

Line 6 & 14 is the error