How To Make A Datastore?

How Do I Make A DataStore?
This Is The Script:

local DataStore = game:GetService("DataStoreService"):GetDataStore("Money")
game.Players.PlayerAdded:Connect(function(plr)
	local leaderstatsFOLDER = Instance.new("Folder", plr)
	leaderstatsFOLDER.Name = "leaderstats"
	
	local ints = Instance.new("StringValue", leaderstatsFOLDER)
	ints.Name = "Job"
	ints.Value = "-"
	
	local money = Instance.new("IntValue", leaderstatsFOLDER)
	money.Name = "Dollars"
	money.Value = 100
	
	local DataStore = game:GetService("DataStoreService"):GetDataStore("Money")
	local Key = plr.UserId
	local Data = DataStore:GetAsync(Key)
	
	if Data then
		Data.Value = Data
	end
end)

game.Players.PlayerRemoving:Connect(function(plr)
	local Key = plr.UserId
	while true do
		wait(0.2)
		DataStore:SetAsync(Key,plr.leaderstats.Dollars.Value)
	end
end)
local fur = pcall(function(plr)
	local Key = plr.UserId
	while true do
		wait(0.2)
		DataStore:SetAsync(Key,plr.leaderstats.Dollars.Value)
	end
end)

But I Wont Work
Note I Tried Turning on Enable Studio Access To API Service But Still Doesnt Work How Do I Do This?

I think it was line 30
local succ, fur = pcall(function(plr)
You forgot the Success in pcall.
I think this topic should go in #help-and-feedback-scripting-support

Full Code
local DataStore = game:GetService("DataStoreService"):GetDataStore("Money")
game.Players.PlayerAdded:Connect(function(plr)
	local leaderstatsFOLDER = Instance.new("Folder", plr)
	leaderstatsFOLDER.Name = "leaderstats"

	local ints = Instance.new("StringValue", leaderstatsFOLDER)
	ints.Name = "Job"
	ints.Value = "-"

	local money = Instance.new("IntValue", leaderstatsFOLDER)
	money.Name = "Dollars"
	money.Value = 100

	local DataStore = game:GetService("DataStoreService"):GetDataStore("Money")
	local Key = plr.UserId
	local Data = DataStore:GetAsync(Key)

	if Data then
		Data.Value = Data
	end
end)

game.Players.PlayerRemoving:Connect(function(plr)
	local Key = plr.UserId
	while true do
		wait(0.2)
		DataStore:SetAsync(Key,plr.leaderstats.Dollars.Value)
	end
end)
local succ, fur = pcall(function(plr)
	local Key = plr.UserId
	while true do
		wait(0.2)
		DataStore:SetAsync(Key,plr.leaderstats.Dollars.Value)
	end
end)

Doesn’t Work Here Is An Error 16:52:36.519 Not running script because past shutdown deadline (x13) - Server

Here Is An Another Error:

  16:59:05.107  DataStore request was added to queue. If request queue fills, further requests will be dropped. Try sending fewer requests.Key = 3348311798 (x5)  -  Studio

So I say to remake your script ):
I can’t remake this script. Your script is everywhere and I don’t know how to make your code work without redoing the all the code(Not trying to be mean)

I can say that there are some post that can help you learn to make datastores.
Here is one that I use: Datastore Tutorial for Beginners

2 Likes

Thank You For The Link And It Worked As Well

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.