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

Can Someone Help Me With my Datastore problem?

Hi I was wondering why this piece of code wont work?

local datastore = game:GetService("DataStoreService"):GetDataStore("Stats")

game.Players.PlayerRemoving:connect(function(player)
player:WaitForDataReady()
datastore:SetAsync(player.Backpack:findFirstChild("Data"),player.Data.Value)
datastore:SetAsync(player.Backpack:findFirstChild("Type").Name,player.Type.Value)
datastore:SetAsync(player.Backpack:findFirstChild("Bp").Name,player.Bp.Value)
end)

game.Players.PlayerAdded:connect(function(newplayer)
newplayer:WaitForDataReady() 


if datastore:GetAsync(newplayer.Backpack.Type.Value) ~= 0 then
Type.Value = datastore:GetAsync(newplayer.Backpack.Type.Value)
if datastore:GetAsync(newplayer.Backpack.Bp.Value) ~= "None" then
newplayer.Bp.Value = datastore:GetAsync(newplayer.Backpack.Bp.Value)
end
end

end)

Thanks

1 answer

It looks like player.Backpack:findFirstChild("Data") is supposed to be player.Backpack:findFirstChild("Data").Name based on the surrounding code and the fact that the first parameter of DataStore:SetAsync expects a string.

1 comment

0

No Data Is Just Something Im Keeping The Strings in

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