Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How will i convert this to store data?? (Long Code)

Asked by 5 years ago
Edited 5 years ago

I am not good at listening, so pls give me a small example from my code or whatever you can :)

---[CODE BY ALEXANDRE (aleandroblingo)]

local Module = {}

function Module:Inject()

end

function onPlayerEntered(newPlayer)
    wait(.5)

    --[]--------------------------------------------------

    --[Settings]
    local CharacterSettings = Instance.new("Configuration")
    local Country =           Instance.new("StringValue")
    local Kart =              Instance.new("StringValue")
    local Livery =            Instance.new("StringValue")

    --[Inventory]
    local Inventory =         Instance.new("Configuration") 

    --[Object Storages]
    local HelmetStorage =     Instance.new("Configuration") 
    local OutFitStorage =     Instance.new("Configuration") 
    local LiveryStorage =     Instance.new("Configuration") 
    local CratesStorage =     Instance.new("Configuration") 

    --[Stats]
    local TrackStatistics =   Instance.new("Configuration")
    local Penalties =         Instance.new("IntValue")
    local Position =          Instance.new("IntValue")
    local Laps =              Instance.new("IntValue")

    --[Skin Settings]
    local BodyColors =        Instance.new("BodyColors")

    --[Extra]
    local TimePlayed =        Instance.new("IntValue")

    --[Cases]
    local CommonCase =        Instance.new("IntValue")
    local UncommonCase =      Instance.new("IntValue")
    local RareCase =          Instance.new("IntValue")
    local ExoticCase =        Instance.new("IntValue")
    local LegendaryCase =     Instance.new("IntValue")
    local GodlyCase =         Instance.new("IntValue")

    --[NAMES]----------------------------------------------

    --[Settings]
    CharacterSettings.Name = "CharacterSettings"
    Country.Name =           "Country"
    Country.Value =          "UK"
    Kart.Name =              "Kart"
    Kart.Value =             "GoKart1"
    Livery.Name =            "Livery"
    Livery.Value =           "Livery1"

    --[Inventory]
    Inventory.Name =         "Inventory"

    --[Object Storages]
    HelmetStorage.Name =     "HelmetStorage"
    OutFitStorage.Name =     "OutFitStorage"
    LiveryStorage.Name =     "LiveryStorage"
    CratesStorage.Name =     "CratesStorage"

    --[Stats]
    TrackStatistics.Name =   "TrackStatistics"
    Penalties.Name =         "Penalties"
    Position.Name =          "Position"     
    Laps.Name =              "Laps" 

    --[Skin Settings]
    BodyColors.Name =        "BodyColors"

    --[Extra]
    TimePlayed.Name =        "TimePlayed"
    TimePlayed.Value =       "0000000000"

    --[Cases]

    CommonCase.Name =        "CommonCase"
    CommonCase.Value =       "0000000020"

    UncommonCase.Name =      "UncommonCase"
    UncommonCase.Value =     "0000000010"

    RareCase.Name =          "RareCase"
    RareCase.Value =         "0000000005"

    ExoticCase.Name =        "ExoticCase"
    ExoticCase.Value =       "0000000003"

    LegendaryCase.Name =     "LegendaryCase"
    LegendaryCase.Value =    "0000000002"

    GodlyCase.Name =         "GodlyCase"
    GodlyCase.Value =        "0000000001"

    --[LOCATIONS]------------------------------------------

    CharacterSettings.Parent = newPlayer

    Inventory.Parent =         newPlayer

    HelmetStorage.Parent =     Inventory
    OutFitStorage.Parent =     Inventory
    LiveryStorage.Parent =     Inventory
    CratesStorage.Parent =     Inventory

    TrackStatistics.Parent =   newPlayer
    Penalties.Parent =         TrackStatistics
    Position.Parent =          TrackStatistics
    Laps.Parent =              TrackStatistics

    TimePlayed.Parent =        CharacterSettings
    BodyColors.Parent =        CharacterSettings
    Country.Parent =           CharacterSettings
    Kart.Parent =              CharacterSettings
    Livery.Parent =            CharacterSettings

    CommonCase.Parent =        CratesStorage
    UncommonCase.Parent =      CratesStorage
    RareCase.Parent =          CratesStorage
    ExoticCase.Parent =        CratesStorage
    LegendaryCase.Parent =     CratesStorage
    GodlyCase.Parent =         CratesStorage



    --[]----------------------------------------------------

end

game.Players.ChildAdded:connect(onPlayerEntered)

return Module

I know its something like this

local ds = game:GetService("DataStoreService"):GetDataStore("stats")

stats={"Reputation","Cash","Exp","MaskColor","MaskPattern","Primary","Secondary","Armor","Equipment"}--change these to whatever stats you want
game.Players.PlayerAdded:connect(function(plyr)
    local a=Instance.new("NumberValue")
    a.Parent=plyr
    a.Name="leaderstats"
    for i=1,#stats do
        local stat=Instance.new("NumberValue")
        stat.Parent=a
        stat.Value=0
        stat.Name=stats[i]
    end
    local child=plyr.leaderstats:GetChildren()
    for i=1, #child do
        child[i].Value=ds:GetAsync(plyr.userId..child[i].Name)
    end
end)

game.Players.PlayerRemoving:connect(function(plyr)
    local child=plyr.leaderstats:GetChildren()
    for i=1, #child do
        child[i].Value=ds:SetAsync(plyr.userId..child[i].Name,child[i].Value)
    end
end)
0
Or will it have to be a complete new code? aleandroblingo -35 — 5y
0
I'm so confused. What are you trying to do, what is your code about. MakeYourEscape 334 — 5y
0
I have no idea what this is but I just want to say your formatting is god-like. angeld23 5 — 5y
0
Basically that script creates a storage in the player like leaderboards and stuff aleandroblingo -35 — 5y

Answer this question