I want it so that everyones money and level saves till the next time they come on. how can I do that in a script?
How can you save everything(that you have done in a game) till the next time you join?
2 answers
I'll cover you up.
What you want is called "DataStores"
That can be done this way:
Insert a script in the workspace, and write this:
--Get 3 services (yah, a lot of stuff going on here)
local DataStoreService = game:GetService("DataStoreService")
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
--The player's money will go here.
local playerMoneyStore = DataStoreService:GetDataStore("PlayerMoneyStore")
--The notification event goes here.
local playerNotificationEvent = Instance.new("RemoteEvent")
playerNotificationEvent.Name = "PlayerNotificationEvent"
playerNotificationEvent.Parent = ReplicatedStorage
--Create the playerMoney table.
local playerMoney = {}
local function onPlayerAdded(player)
--get player's id.
local playerId = tostring(player.UserId)
--if successful, then return playerMoneyStore, defined a bit ahead.
local success, money = pcall(function()
return playerMoneyStore:GetAsync(playerId)
end)
if success then
playerMoney[player] = money
else
--Say there's an error on saving data.
playerNotificationEvent:FireClient(player, "Error retrieving saved data: please try again later")
end
-- Do other player initialization code
end
Players.PlayerAdded:Connect(onPlayerAdded)
See if that works.
As always, good scripting
Since you're not giving much detail, there's not much we can do. However, I think what you want to do is to learn how to use DataStores. DataStores allow you to hold data on the server, meaning you can save player data from one play session to the next.
If you do decide to use DataStores, here are some links that will help. Data store Ordered Data Stores
1 comment
Yeah, your answer is definitely better than the choosen one. Is people blind? Don't they see while they're asking their question that wonderfull "Scripting helpers is NOT a request site"!?
This discussion is preserved as it was. New answers, comments, and votes are closed.

7 comments
Dose it work with leaderboard?
Yes, It is meant to work with leaderstats.
Oh, but if I'm right, that script will only work in the actual game, and not in Roblox Studio. Anyways, If it won't work in the roblox studio, try in the actual game first.
(I have 3 columns that have to be saved in the leaderboard "Level, Money and EXP) Dose it still work?(sorry for asking too many questions)
No problem, but yes, it should work. Test it out dude! :P
Works!
:D Glad to hear.