So yeah, I was trying to make a backpack storage Gui. Obviously, I tried to put the two values (BackpackStorageUsed, BackpackStorage) into a folder inside the player because everyone would have different used amount of storage. So, I tried it and in the Output it said:
09:04:08.890 - ServerScriptService.Script:15: attempt to index local 'player' (a nil value)
Can anyone help? I have two scripts; one ClickDetector script so that when I click it, the BackpackStorageUsed value will go up by one, and the other is to keep updating the Gui and to create all the values when the player joins:
local Backpack = Instance.new("Folder")
local player = game.Players.LocalPlayer
local BackpackStorageUsed = Instance.new("IntValue", Backpack)
local BackpackStorage = Instance.new("IntValue", Backpack)
local BackpackIndicator = game.StarterGui.BackpackGui.BackpackIndicator
Backpack.Name = "Backpack"
Backpack.Parent = player
BackpackStorageUsed.Name = "BackpackStorageUsed"
BackpackStorage.Name = "BackpackStorage"
BackpackStorage.Value = 10
BackpackStorageUsed.Value = 0
while wait() do
script.Parent.Parent.StarterGui.BackpackGui.BackpackIndicator.Text = "Bag: " ..player.Backpack:FindFirstChild("BackpackStorageUsed").Value.. "/" ..player.Backpack:FindFirstChild("BackpackStorage").Value
end
Here's the other one:
local GiantBone = game.Workspace.GiantBone
local BackpackStorageUsed = game.Players.LocalPlayer.Backpack.BackpackStorageUsed
local BackpackStorage = game.StarterGui.BackpackGui.BackpackIndicator.BackpackStorage
GiantBone.ClickDetector.MouseClick:Connect(function()
BackpackStorageUsed.Value = BackpackStorageUsed.Value + 1
if BackpackStorageUsed.Value == BackpackStorage.Value then
GiantBone.ClickDetector.MaxActivationDistance = 0
if BackpackStorageUsed.Value == BackpackStorageUsed.Value > BackpackStorage.Value then
GiantBone.ClickDetector.MaxActivationDistance = 32
end
end
end)

2 comments
Is this being done in a ServerScript?
Yes.