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

solved need help with save the save won´t go higher than 10 please help ?

Asked by 5 years ago
Edited 5 years ago

I am saving 3 values when i load in the values are not what they should have saved as the first value mul should have saved as 1 but is saves as 0 and the plrstats should have saved at 100 in the output it says nothing a on it

local ds=game:GetService("DataStoreService"):GetDataStore("tylergoatboy4282")
local fol=Instance.new("Folder",game.ServerStorage)
fol.Name='PlayerMoney'

game.Players.PlayerAdded:Connect(function(plr)
    local id='id-'..plr.UserId
    --leaderstats and save stats--
    local plrstats = Instance.new("NumberValue",fol)
    local mul=Instance.new('IntValue',plrstats)
    local save=Instance.new('NumberValue',plrstats)
    local OwnsTycoon=Instance.new('ObjectValue',plrstats)
    OwnsTycoon.Name='OwnsTycoon'
    mul.Name='mul'
    plrstats.Name=plr.Name
    save.Name='save'
    mul.Value=1
    plrstats.Value=0

    --getasink--
    local getsave=ds:GetAsync(id)
    if getsave then
     plrstats.Value = getsave[1]
     mul.Value=getsave[2]
     save.Value=getsave[3]
else 
  local  NumbersForSaving = {plrstats.Value..mul.Value..save.Value}
  ds:SetAsync(id, NumbersForSaving)

    end
end)


game.Players.PlayerRemoving:Connect(function(plr)
    local id='id-'..plr.UserId
    local sa=game.ServerStorage.PlayerMoney:FindFirstChild(plr.Name)
    local savetable={sa.Value..sa.mul.Value..sa.save.Value}
    ds:GetAsync(id,savetable)
    end)

0
any errors in the output hellmatic 1523 — 5y
0
User variable names that make sense and show what they contain. Never use non word and one letter variables. User#21908 42 — 5y
0
what tylergoatboy 82 — 5y
0
Please provide more than just a brief sentence if you're going to dump 50 lines of code. Is there anything in the output? vanilla_wizard 336 — 5y
View all comments (5 more)
0
there is nothing in the output tylergoatboy 82 — 5y
0
did you enable studio access to api services hellmatic 1523 — 5y
0
on line 37 you are trying to save data with :GetAsync(). Think about that for a moment. User#21908 42 — 5y
0
:SetAsync() works thanks  tylergoatboy 82 — 5y
0
No problem, be sure to put [Solved] in your title so that people know that you no longer need help. User#21908 42 — 5y

Answer this question