#Help with Leaderstats script

49 messages · Page 1 of 1 (latest)

clear oak
#

I'm using a car dealership scipt, and my initial leaderstats script (pictured 1st), is the one that I want to manage the dealership (with Money being the only factor), and the bottom script is the leaderstats script from the Dealership model. Thank you for your help

#

I don't want the wallet + bank system pictured on the right side

crimson star
#

Can add more stats to this like coins, levels, anything you want just change where it says examples and follow that format to create more (or delete it), then i have money defaulted to 6500 if the player doesnt have data yet, and another example one incase you want to add more, you can delete if you dont need it

local playerDataStore = DataStoreService:GetDataStore("Dealership")

game.Players.PlayerAdded:Connect(function(player)
    local leaderstats = Instance.new("Folder")
    leaderstats.Name = "leaderstats"
    leaderstats.Parent = player
    local values = {}
    for _, name in ipairs({"Money", "EXAMPLE"}) do
        local value = Instance.new("IntValue")
        value.Name = name
        value.Parent = leaderstats
        values[name] = value
        if value.Name == "Money" then
            value.Value = 6500
        --elseif value.Name == "EXAMPLE" then
            --value.Value = NUMBER
        end
    end
    local success, data = pcall(function()
        return playerDataStore:GetAsync(player.UserId)
    end)
    if success and data then
        for name, value in pairs(values) do
            value.Value = data[name] or 0
        end
    end
end)

game.Players.PlayerRemoving:Connect(function(player)
    local values = {}
    local leaderstats = player:FindFirstChild("leaderstats")
    if leaderstats then
        for _, value in ipairs(leaderstats:GetChildren()) do
            if value:IsA("IntValue") then
                values[value.Name] = value.Value
            end
        end
        playerDataStore:SetAsync(player.UserId, values)
    end
end)```
clear oak
#

thank you so much

#

im going to test it out right now

crimson star
#

you have to delete where it says examples if you dont want those extra ones

clear oak
#

alright so that script fixed the leaderstats, but now I have seperate issue with the script that the leaderstats one calls to

#

this script is super long so i'm going to put it into pastebin if thats alright

#

i think the issue with it is the beginning of the script that calls to bank data and wallet data

grand briarBOT
#

studio** You are now Level 1! **studio

crimson star
#

i'm not good with saving anything other than numbers sorry

clear oak
#

its alright thank you though

queen trench
clear oak
#

Well the script that handles the spawning of cars still relies on the old script which uses Bank Data and Wallet Data which aren't the stats that i want to be used (money)

primal drift
primal drift
clear oak
#

i honestly just do not know how to do that

crimson star
clear oak
#

im a terrible scripter and its confusing to me

crimson star
#

same ong

primal drift
#

bruh im going to create one for u then

#

lol jk i have a friend that does the scripts for me

clear oak
#

but it doesn't correlate to my leaderstats so all i need help with is converting it sort of?

primal drift
#

its a DataStore system that handles String, Bools, Number, Int and DoubleConstrainedValues

primal drift
clear oak
#

i was doing some other things i'll check it rn

primal drift
#

also he does things that have tips on what it does

clear oak
#

im going to work on this tomorrow because for now, i can't get it working and it's getting late

#

thank you for your help i'll let you know tomorrow if it works for me 😄

primal drift
#

lol it took him 3 minutes to create that script

clear oak
#

could not it to work 🤣

primal drift
clear oak
#

get it to work

grand briarBOT
#

studio** You are now Level 2! **studio

clear oak
#

idk wtf i was typing

primal drift
clear oak
primal drift
#

@clear oak

clear oak
#

okay putting it in rn

primal drift
#

all i did was remodified it as he told me since im still new also

#

but everything is added to the folder

#

if u want to add new things to the Folder in the Handler just lua local Handler = { ['Folders'] = { {key = 'leaderstats'}, {key = 'NewName'} -- creates a new folder to the newFolder handler function }, ['ls'] = { {key = 'Cash',Value = 0}, {key = 'Hommie',Value = 0}, {key = 'Nerd',Value = 0}, {key = 'Rebirth',Value = 0} }, ['newValues'] = { {key = 'Name',Value = 0}, }, -- same as the ls }

clear oak
#

thank you