Log in to vote

How do I create a String from a leaderstat Inventory?

Asked by 7 months ago
Edited 7 months ago

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

    local folder ="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"
        local stat =
        stat.Name = name
        if value then stat.Value = value end
        stat.Parent = folder

Just to clarify this script is not my attempt to find the item

Where is the script showing your attempt to find the item then? Knowing what you have tried already would be helpful. Sparks 534 — 7mo

Answer this question