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

I'm having issues with data store?

Here's the script: It always attempts to load but says there isn't anything there, im sure the problem is at the green dashed line.

DataStore = game:GetService("DataStoreService"):GetDataStore("BSI")
Players = game:GetService("Players")

game.Players.PlayerAdded:connect(function(player)

local Kills = Instance.new("IntValue", leader)
	Kills.Name = "Kills"
	
	local key = "user "..player.userId
	local Saved = DataStore:GetAsync(key)
	print (Saved[1])
	Kills.Value = Saved[1] or 0
	DataStore:SetAsync(key, Saved[1])
	print (key, Saved[1])
end)

game.Players.PlayerRemoving:connect(function(player)
	local key = "user "..player.userId
	print (key.." left")
	local ToSave = player.leaderstats.Kills.Value
	print (ToSave.." value")
	DataStore:SetAsync(key, 1 == ToSave) -----------------------
	print (key, ToSave)
	print 'SAVED'
end)

2 comments

0

Why are you trying to save a condition as a value, why not just use the ToSave variable?

0

Are you trying to save the true or false condition?

1 answer

✓ Accepted answer

If you're trying to save a condition, then on line 22, it has to be "ToSave == 1." This is because the computer thinks like "this value is this number," not "this number is this value."

1 comment

0

The order that line 22 was in was correct for what I was trying to do, it just doesn't work for this all together, "1" was the index of a table, not the value

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