so i made a simple script which changes a value to player items amount.
local value = script.Parent local plrname = game.Workspace:WaitForChild("PlayerName") local plr = game.Players:WaitForChild(plrname.Value) local inv = plr:WaitForChild("Inventory") while true do wait(0.5) value.Value = #inv:GetChildren() end
why its not working
I think the problem is that Inventory
isn't a valid member of the player. Instead, try using Backpack
. Also, I would use the PlayerAdded
event. This is the script I would use:
local value = script.Parent local Players = game:GetService("Players") Players.PlayerAdded:Connect(function(player) local backpack = player:WaitForChild("Backpack") local function checkForItems() while true do wait() value.Value = #backpack:GetChildren() end end spawn(checkForItems) end)