I’m am currently trying to make a kind of loadout system for a game Im working on.
Anyway I keep getting an error when trying to access the player’s backpack, " attempt to index nil with ‘FindFirstChild’ ", " attempt to index nil with ‘WaitForChild’ " etc…
Hopefully some people who are smarter than me can help out.
local player = game:GetService("Players").LocalPlayer
local primary = game.ReplicatedStorage.Weapons:WaitForChild("AK74N")
local secondary = game.ReplicatedStorage.Weapons:WaitForChild("X16")
local function loadoutGive(player)
primary:Clone()
primary.Parent = player:WaitForChild("Backpack") --error
secondary:Clone()
secondary.Parent = player:WaitForChild("Backpack") --error
end
game.ReplicatedStorage.RemoteEvents.RemoteEventPlay.OnServerEvent:Connect(function(player)
loadoutGive()
end)
local primary = game.ReplicatedStorage.Weapons:WaitForChild("AK74N")
local secondary = game.ReplicatedStorage.Weapons:WaitForChild("X16")
local function loadoutGive(player)
primary:Clone()
print(player.Name) --checking to see it works
primary.Parent = player:WaitForChild("Backpack") --error
secondary:Clone()
secondary.Parent = player:WaitForChild("Backpack") --error
end
game.ReplicatedStorage.RemoteEvents.RemoteEventPlay.OnServerEvent:Connect(function(player)
loadoutGive(player)
end)