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

DataStore no saving data ?

Asked by 5 years ago
Edited 5 years ago
local Data = game:GetService('DataStoreService'):GetDataStore('hsahahha')

local prefix = 'user_' 

game.Players.PlayerAdded:connect(function(player)
    local Data = Instance.new("Folder",player)
    Data.Name = "Data"
local agility = Instance.new("NumberValue", Data)
    agility.Name = "Agility"
    local Strength = Instance.new("NumberValue", Data)
    Strength.Name = "Strength"
    local defense = Instance.new("NumberValue", Data)
    defense.Name = "Defense"
    local inteligency = Instance.new("NumberValue",Data)
    inteligency.Name = "Inteligency"
    local StatPoints = Instance.new("NumberValue", Data)
    StatPoints.Name = "StatPoints"
    local race = Instance.new("StringValue", Data)
    race.Name = "Race"
    local xp = Instance.new("IntValue", Data)
    xp.Name = "XP"
    local level = Instance.new("NumberValue",Data)
    level.Name = "Level"
        local plrData = Data:GetAsync(prefix  .. tostring(player.UserId))
        if plrData then
        Strength.Value = plrData[1] or 1
        defense.Value = plrData[2] or 1
        StatPoints.Value = plrData[2] or 1
        race.Value = plrData[3] or "Human"
        xp.Value = plrData[4] or 1
        level.Value = plrData[5] or 1
        inteligency.Value = plrData[6] or 1
end

game.Players.PlayerRemoving:connect(function(player)
    Data:SetAsync(prefix  .. tostring(player.UserId), {
        player.Data.Agility.Value,
        player.Data.Strength.Value,
        player.Data.Defense.Value,
        player.Data.StatPoints.Value,
        player.Data.Race.Value,
        player.Data.XP.Value,
        player.Data.Level.Value,
        player.Data.Inteligency.Value
    })
end)

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

You're missing an apostrophe in your GetDatastore()

local Data = game:GetService('DataStoreService'):GetDataStore('hsahahha)

Also all of your lines where you do this:

agility.Value = player.Data.Agility.Value

are completely unncessary, you're copying the value of the exact value to itself.

After your if plrData then if statement you do close the if itself but you don't close the function of the PlayerAdded event anymore.

0
this apostrophe " ' " Already have, I accidentally deleted it at the time of posting Diguinho4321 -8 — 5y
0
I already solved some things you said, but still not saving Diguinho4321 -8 — 5y
0
"Fixed" is my Add stats menu no save points Diguinho4321 -8 — 5y
Ad

Answer this question