I tried to save my data store with adding a halo making it so if you buy the halo, you can keep the halo when you join back using a bool value, but it does not seem to work! Please help me.
local datastore = game:GetService("DataStoreService") local coindata = datastore:GetDataStore("CoinData") local chalodata = datastore:GetDataStore("chalodata") game.Players.PlayerAdded:Connect(function(player) local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" leaderstats.Parent = player local coin = Instance.new("IntValue") coin.Parent = leaderstats coin.Name = "Rixels" local chalo = Instance.new("BoolValue") chalo.Parent = player chalo.Name = "CHalo" local playerUserId = "Player_"..player.UserId --The part of the DataStore-- local success, errormessage = pcall(function() data = coindata:GetAsync(playerUserId) data2 = chalodata:GetAsync(playerUserId) end) if success then coin.Value = data chalo.Value = data2 end end) game.Players.PlayerRemoving:Connect(function(player) local playerUserId = "Player_"..player.UserId local data = player.leaderstats.Rixels.Value local data2 = player.CHalo.Value local success, errormessage = pcall(function() coindata:SetAsync(playerUserId, data) chalodata:SetAsync(playerUserId, data2) end) if success then print("Data is saved!") else print("there was a error") print(errormessage) end end)