wait(3) print("Script is now running, Saving Data...") local DSService = game:GetService("DataStoreService"):GetDataStore("EmoteSimCashData") game.Players.PlayerAdded:Connect(function(plr) local playerId = "id-"..plr.UserId local DataToSave = plr.PlayerGui.Amount.Frame.Balance local GetSaved = DSService:GetAsync(playerId) if GetSaved then DataToSave.Value = GetSaved[1] else local NumbersForSaving = {DataToSave.Value} DSService:SetAsync(playerId,NumbersForSaving) end end) game.Players.PlayerRemoving:Connect(function(plr) local playerId = "id-"..plr.UserId local Savetable = {plr.DataToSave.Value} DSService:SetAsync(playerId,Savetable) end)
I want to know why this script is only running in Solo Studio, and not In-game. Any Idea why?
Thanks in advance.
It might be because of the game was closing and didn't have time to run the PlayerRemoving event. For this reason, Roblox have game:BindToClose(). You might wanna read that ;)