Idk what is going on here, can some explain?
local datastoreservice = game:GetService("DataStoreService")
local mystore = datastoreservice:GetDataStore("mydatastore")
game.Players.PlayerAdded:Connect(function(player)
local OtherStuff = Instance.new("Folder",player)
OtherStuff.Name = "OtherStuff"
local rebirths = Instance.new("StringValue",OtherStuff)
rebirths.Name = "rebirths"
rebirths.Value = 1
local rebirthcost = Instance.new("StringValue",OtherStuff)
rebirthcost.Name = "rebirthcost"
rebirthcost.Value = 100
local playerid = "Player_" .. player.UserId
local data = mystore:GetAsync(playerid)
if data then
rebirths.Value = data['rebirths']
rebirthcost.Value = data['rebirthcost']
else
rebirths.Value = 10
rebirthcost.Value = 100
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local datatobesaved = {
rebirths = player.OtherStuff.rebirths.Value;
rebirthcost = player.OtherStuff.rebirthcost.Value;
}
local playerid = "Player_" .. player.UserId
local success, err = pcall(function()
mystore:SetAsync(playerid,datatobesaved)
end)
if success then
print("data saved!")
else
print("data faield to save!")
end
end)
line 24 btw