I’ve been learning how to create a datastore script but the problem is that I didn’t find information on how to make one with more than 2 values and I didn’t succeed in making one.
The script I made (ignore the two lines related to a remote event):
local DataStoreService = game:GetService(“DataStoreService”)
local Teststorage = DataStoreService:GetDataStore(“TestCoin1”)
game.Players.PlayerAdded:Connect(function(player)
local data
local success, erro = pcall(function()
data = Teststorage:GetAsync(player.UserId…“TestCoin1”)
end)
if success then
player.DataStore.TestCoin1.Value = data
local p = “recuperado”
game.ReplicatedStorage.Events.Assets.DataStore:FireClient(player , p)
else
print(“dont work”)
warn(erro)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local sucess,erro = pcall(function()
Teststorage:SetAsync(player.UserId…“TestCoin1”,player.DataStore.TestCoin1.Value)
end)
if sucess then
print("saved")
else
print("dont saved")
warn(erro)
end
end)
I couldn’t put the value “TestCoin2” inside the script so is there a way to put “TestCoin2” inside the script?