How to make a ROBLOX DATASTORE in Roblox Studio (Roblox Studio 2022)

Опубликовано: 06 Май 2026
на канале: JackTheMonster
3,350
59

Hey guys! This video was requested by Bug 07 in the comments section of my last video. If you want to see a specific video on how to do something in Roblox studio, just let me know in the comments! If you found this video helpful in any way, please leave a like and subscribe to my channel! It's completely free!

==---------------------------------------------------==
🚨My Youtube Channel (Subscribe!)🚨:    / jackthemonster  

Roblox Profile: https://web.roblox.com/users/52985941...

Roblox Group: https://web.roblox.com/groups/5028136...

-DataStore Script:-

local ds = game:GetService("DataStoreService"):GetDataStore("CashData50")

game.Players.PlayerAdded:Connect(function(plr)
wait()

local key = "user_"..plr.UserId

local saveValue1 = plr.leaderstats.Cash
local saveValue2 = plr.leaderstats.Rebirths

local getSaved = ds:GetAsync(key)

if getSaved then
saveValue1.Value = getSaved[1]
saveValue2.Value = getSaved[2]
else
local NumbersForSaving = {saveValue1.Value, saveValue2.Value}

ds:GetAsync(key, NumbersForSaving)
end
end)

game.Players.PlayerRemoving:Connect(function(player)
local saveValue1 = player.leaderstats.Cash
local saveValue2 = player.leaderstats.Rebirths

ds:SetAsync("user_"..player.UserId, {saveValue1.Value, saveValue2.Value})
end)

-Leaderstats Script:-
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local cash = Instance.new("IntValue")
cash.Name = "Cash"
cash.Parent = leaderstats
local rebirths = Instance.new("IntValue")
rebirths.Parent = leaderstats
rebirths.Name = "Rebirths"
end)

---------------------------------------------------------------------------------------------------


I'm making a new Roblox Game soon! Stay tuned for a video about it in the future!