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

Data Storage of String Value not working, Why?

Asked by
PastDays 108
5 years ago
Edited 5 years ago

This script was originally written by 'Alvin' the YouTuber and I edited it to try to save a string value, why isn't it loading the String Value? Can you not save String Values?

local DSService = game:GetService('DataStoreService'):GetDataStore('ProjectFalcon_B')
game.Players.PlayerAdded:connect(function(plr)
    -- Define variables
    local uniquekey = 'id-'..plr.userId
    local Player_Config = Instance.new('IntValue', plr)
    local Skin_Tone =  Instance.new('StringValue')
    Player_Config.Name = 'Player_Config'
    Skin_Tone.Parent = Player_Config
    Skin_Tone.Name = 'Skin_Tone'

    -- GetAsync
    local GetSaved = DSService:GetAsync(uniquekey)
    if GetSaved then
        Skin_Tone.Value = GetSaved[1]
    else
        local NumbersForSaving = {Skin_Tone.Value}
        DSService:SetAsync(uniquekey, NumbersForSaving)
    end
end)

game.Players.PlayerRemoving:connect(function(plr)
local uniquekey = 'id-'..plr.userId
local Savetable = {plr.Player_Config.Skin_Tone.Value}
DSService:SetAsync(uniquekey, Savetable)    


end)

1 answer

Log in to vote
0
Answered by 5 years ago

Try this

local DSService = game:GetService('DataStoreService'):GetDataStore('ProjectFalcon_B')
game.Players.PlayerAdded:connect(function(plr)
    -- Define variables
    local uniquekey = 'id-'..plr.userId
    local Player_Config = Instance.new('IntValue', plr)
    local Skin_Tone =  Instance.new('StringValue')
    Player_Config.Name = 'Player_Config'
    Skin_Tone.Parent = Player_Config
    Skin_Tone.Name = 'Skin_Tone'

    -- GetAsync
    local GetSaved = DSService:GetAsync(uniquekey)
    if GetSaved then
        Skin_Tone.Value = GetSaved[1]
    else
        local NumbersForSaving = {plr.Player_Config.Skin_Tone.Value}
        DSService:SetAsync(uniquekey, NumbersForSaving)
    end
end)

game.Players.PlayerRemoving:connect(function(plr)
local uniquekey = 'id-'..plr.userId
local Savetable = {plr.Player_Config.Skin_Tone.Value}
DSService:SetAsync(uniquekey, Savetable)    


end)
0
No it still didn't work. PastDays 108 — 5y
Ad

Answer this question