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

Can Someone Help Me With my Datastore problem?

Asked by 10 years ago

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

Log in to vote
0
Answered by
1waffle1 2908 Trusted Badge of Merit Moderation Voter Community Moderator
10 years ago

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.

0
No Data Is Just Something Im Keeping The Strings in pikamew9998 0 — 10y
Ad

Answer this question