If I used data store to save a value in one place, how would I get that saved value in the other place?
Data Store script in the first place:
local quirkstore = game:GetService("DataStoreService"):GetDataStore("Quirk")
game.Players.PlayerAdded:connect(function(plr)
local stats = Instance.new("IntValue", plr)
stats.Name = "leaderstats"
local quirk = Instance.new("StringValue", stats)
quirk.Name = "Quirk"
quirk.Value = quirkstore:GetAsync(plr.userId) or ""
quirkstore:SetAsync(plr.userId, quirk.Value)
end)
game.Players.PlayerRemoving:connect(function(plr)
print("Saving Player Data")
quirkstore:SetAsync(plr.userId, plr.leaderstats.Quirk.Value)
print(plr.leaderstats.Quirk.Value.." Has been saved")
end)

1 comment
If you are talking about different places that aren't a part of the same Game (There is a difference between these) you cannot access the data store. If they are in the same game, you would simply connect to the data store the same way you did in this script.