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

DataStore no saving data ?

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

✓ Accepted answer

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.

3 comments

0

this apostrophe " ' " Already have, I accidentally deleted it at the time of posting

0

I already solved some things you said, but still not saving

0

"Fixed" is my Add stats menu no save points

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