So what I'm trying to do is detect a certain item in a leaderstats inventory (sound code) to then play said sound to the whole server.
Ive tried to search for it in leaderstats but I don't know if i wrote my code wrong or this isn't the way to do it
local players = game:GetService("Players") local stats = { {"Cash", 20000}, {"Items", 0}, {"Inventory", nil} --Right here } players.PlayerAdded:Connect(function(player) local folder = Instance.new("Folder") folder.Name = "leaderstats" folder.Parent = player for i,v in pairs(stats) do local statType = "IntValue" local name = v[1] local value = v[2] if type(value) == "boolean" then statType = "BoolValue" elseif type(value) == "string" then statType = "StringValue" elseif value == nil then statType = "Folder" end local stat = Instance.new(statType) stat.Name = name if value then stat.Value = value end stat.Parent = folder end end)
Just to clarify this script is not my attempt to find the item