Backpack not being found?

can someone explain why this isn’t working

local p = game.Players.LocalPlayer
local par = script.Parent
local rs = game:GetService("ReplicatedStorage")

if p.Backpack.Vessels.HasFrisk.Value == false then
	script.Parent.ImageColor3 = Color3.fromRGB(50,50,50)
end 

par.MouseButton1Click:Connect(function()
	if p.Backpack.Vessels.HasFrisk.Value == true then
		workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
		
		rs.Remotes.Selected:FireServer("Frisk")
		print("worked")
	end
end)

additional info:
CharacterAutoLoads = false
This is a local script
happens as soon as I start the game

1 Like

Maybe the backpack isn’t loaded yet? Try to give some time to the player for loading.

1 Like

image
right as the game starts btw

1 Like

Try to put this after getting the player and then show what happens?

local char = p.Character or p.CharacterAdded:Wait()

or you can also do

local Backpack = game.Players.LocalPlayer:WaitForChild('Backpack')
1 Like

Just for your info, if you get this kind of error for anything else, although the instance does exist, it’s best to use WaitForChild, as the script may have run before the instance has loaded. So next time, use WaitForChild if you get this kind of error again.

Example:
Instead of

local backpack = game.Players.LocalPlayer.Backpack

Do

local backpack = game.Players.LocalPlayer:WaitForChild("Backpack")
2 Likes