Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Data Storage of String Value not working, Why?

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

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)

1 comment

0

No it still didn't work.

This discussion is preserved as it was. New answers, comments, and votes are closed.