Data stored within a datastore transfer between places. However, it does not transfer between different universes. If you want someone to have a sword within two completely different games, you'd have to use an external database.
If you just want to have a sword within two different places in a universe, then you'd have to save the sword's ID via a Datastore's GetAsync and SetAsync methods:
Players.PlayerAdded:Connect(function(player)
local id = tostring(player.UserId);
local attempts = 5;
local data;
repeat
_, data = pcall(function()
return DataStore:GetAsync(id) or {};
end)
attempts = attempts - 1;
until data or (attempts <= 0);
data = data or player:Kick("Data failed to load. Please try again later.");
if (data.Sword) then Sword:Clone().Parent = player.StarterGear end;
end);
Players.PlayerRemoving:Connect(function(player)
local id = tostring(player.UserId);
pcall(function()
return DataStore:SetAsync(id, {Sword = player.StarterGear:FindFirstChild('Sword') and true});
end);
end);
..Something like that. Cheers.
1 comment
Both of your answers were very helpful. Thanks for the information and I will plan to use it in the future.