Help with setting and removing data from a data stores [URGENT]

I am not speaking to you. You can still fire them with exploits regardless.

Iā€™m only saving the data for the one player ā€¦ spamming it in any form isnā€™t going to matter.

:wink:

Iā€™m not here to debate you ā€¦ thatā€™s your program. I do checks for anything odd.
Then kick and permanently ban the player. Your 1st hack call would earn you that.

I was thinking ā€¦ if youā€™re still having problems try to rem off them pcall calls.
Sometimes that can show an error you wouldnā€™t see otherwise. You do have API set to on correct?
Also, alessdai has a valid point ā€¦ Why are you sending data reads/saves via remotes? Itā€™s hard enough to debug these data stores the way it is. Anything Iā€™m telling you could be totally off considering everything else youā€™re doing. Iā€™m commenting on what Iā€™ve posted.
They can set off your remotes unless youā€™re really set up to catch that ā€¦

1 Like

The way itā€™s set up, the player canā€™t spam the remote event. Plus, thereā€™s nothing to gain from spamming it if you figure out a way to.

I removed the pcalls, and it wonā€™t do anything, but it doesnā€™t show any errors. Yes, I have API on. Iā€™m using remotes because I want to add a player to the store when they pass a test done via gui, and I want to remove players from the store when I click a gui button.

Doesnā€™t it use user ids to remove data? Iā€™m using player names, not user ids.

You need to use whatever you used for your key ā€¦ most do use the player ID. The fact your Data Store can be spammed with remotes should be unacceptable. I do, do checks for odd actions but I also donā€™t open up the front door for hackers. It also makes helping you next to impossible with a data system I would never use or care to debug. Data Stores kind of throw fits about how they work. Itā€™s far from consistent behavior when it comes to timing. Adding remotes to that would make it next to impossible to know where the timing error was.

1 Like

Is there any other way I could communicate between server and client? Also, what makes the 300 robux data store editor better than all the other free ones? Looking at the comments, there are some concerning ones that make me think it might be a waste of 300 robux. Iā€™ve already tried some of the free ones, and they donā€™t work, so why would this work?

I used it to delete data and more so to look at the data checking if everything is working ok. Seems to work fine. You could do everything it can yourself however. Only tool Iā€™ve paid for. Itā€™s nothing that great but itā€™s can do what it says ā€¦ I think you should try looking at using the IDs ā€¦
something like dataKey:SetAsync(plr.CharacterAppearanceId,plr.leaderstats.Coins.Value)
Why are you not just using what I posted, modified ā€¦

1 Like

You could clog all requests and basically make a server dysfunctional. Whatā€™s that? Little jimmy wants his progress to be saved? Nope!! :x::x::x::x:

1 Like

Ok, I think I pretty much understand now. Since my setup looks pretty similar to the example one you showed, the problem must be with the remote events like yā€™all suggested. So what can I use instead of remote events. To understand why I kinda need them, hereā€™s the context:

So, long story short, Iā€™m making a restaurant business. These scripts are for the application center, where customers can take a 10 question test, and, if they pass, they can become a trainee. I tried to use a auto-ranking system with noblox.js, but I got REALLY confused, so I went with this instead. Now, I want to have them take the test, and, if they pass, their name is added to a dataStore. Iā€™d prefer their name because on roblox, you cant search for players by userId. Later, Iā€™ll join in, and since I am high enough rank in the group, a script will read all items of the data store, then it will fire a remote event to me to make a gui for each key(player name). Hereā€™s where the remote events come in. I have two concepts to work with: gui and DataStores. DataStores can only be accessed through a server-side scripts, and gui must be worked with on the client side. Otherwise, the client wouldnā€™t be able to see the gui changes. The only way I can think of to communicate is RemoteEvents, so we have 3(?) options I can think of:

  1. Use something other than remote events to communicate between server and client.
  2. Change the scripts some way to make it work with RemoteEvents
    3? Take advantage of ReplicatedStorage(might not work)

PS: Thank you for your patience, took me quite a while to understand.

Ah, I see. So, what could I use other than RemoteEvents?

I just realized Iā€™m been giving you examples of an ordered data store. /facepalm

1 Like

Also ā€¦ I am sorry I didnā€™t see that GetOrderedDataStore, again /facepalm
1/2 this hassle has been my fault. :unamused:

You may want to start a whole new program for that also ā€¦ I know I know

GetOrderedDataStore is for a high score board. But you can do that other ways with just pulling the data. Once you get this down you can mess around with GetOrderedDataStore itā€™s pretty much the same thing. Also calling both them together like that in the pcall is a bit sloppy.

*Edit You do have to slipt them up and make 2 pcalls

last one ā€¦


local Player                                                 --- Addded this just for the test on the bottom remove it

--------------------------------
local dataStoreService = game:GetService("DataStoreService")
local CoinKey = dataStoreService:GetDataStore("Coins")
local LevelKey = dataStoreService:GetDataStore("Level")


game.Players.PlayerAdded:Connect(function(plr)
	Player = plr.Name                                        --- Addded this just for the test on the bottom remove it
	local Iv, ls = nil, Instance.new("Folder")
	ls.Name = "leaderstats" ls.Parent = plr
	Iv = Instance.new("IntValue")
	Iv.Name = "Level" Iv.Parent = ls
	Iv = Instance.new("IntValue")
	Iv.Name = "Coins" Iv.Parent = ls
	
	local sus, err = pcall(function()
		ls:WaitForChild("Level").Value = LevelKey:GetAsync(plr.UserId, "Level") or 0
	end) if not sus then warn(err) end
	local sus, err = pcall(function()
		ls:WaitForChild("Coins").Value = CoinKey:GetAsync(plr.UserId, "Coins") or 0
	end) if not sus then warn(err) end
end)
game.Players.PlayerRemoving:Connect(function(plr)
	local sus, err = pcall(function()
		LevelKey:SetAsync(plr.UserId, plr.leaderstats.Level.Value)
	end) if not sus then warn(err) end	
	local sus, err = pcall(function()
		CoinKey:SetAsync(plr.UserId, plr.leaderstats.Coins.Value)
	end) if not sus then warn(err) end
end)
--------------------------------

wait(3)                                                                      ---        Remove this test also
game.Players:WaitForChild(Player).leaderstats.Coins.Value = 4                ---
game.Players:WaitForChild(Player).leaderstats.Level.Value = 4    
1 Like

Oh, so I could make the fact whether they passed or not a boolean value, and then, when they leave, it will save to the data store. That would eliminate the need for remote events to set the keys. How could I do it to remove the keys?

Oh wait, could I make it a command to remove keys to eliminate the use of remote events?

It will if you change their level ā€“ Iā€™m talking about the last script I posted

Ok here are my scripts with the new changes, can you see if these look good?
Hereā€™s the script that when I join the game, it gets whether Iā€™ve passed or not:

local Players = game:GetService("Players")

local DataStoreService = game:GetService("DataStoreService")
local passStore = DataStoreService:GetDataStore("PassStore")

Players.PlayerAdded:Connect(function(plr)
	local success, value = pcall(function()
		return passStore:GetAsync(plr.UserId)
	end)
	
	local statsFolder = Instance.new("Folder")
	statsFolder.Name = "StatsFolder"
	statsFolder.Parent = plr
	
	local pass = Instance.new("BoolValue")
	pass.Name = "Pass"
	pass.Parent = statsFolder
	if success then
		pass.Value = value
	else
		pass.Value = false
	end
end)

Hereā€™s the script that adds me to the data store when I leave if Iā€™ve passed:

local DataStoreService = game:GetService("DataStoreService")
local passStore = DataStoreService:GetDataStore("PassStore")

local Players = game:GetService("Players")

Players.PlayerRemoving:Connect(function(plr)
	local statsFolder = plr:WaitForChild("StatsFolder")
	local pass = statsFolder:WaitForChild("Pass")
	
	if pass == true then
		local success, errorMessage = pcall(function()
			passStore:SetAsync(plr.UserId, true)
		end)
		if not success then 
			warn(errorMessage)
		end
		if success then
			print(plr.UserId)
		end
	end
end)

Hereā€™s the script that removes the player from the data store when I type a command:

local commands = {}

local prefix = "/"

local DataStoreService = game:GetService("DataStoreService")
local passStore = DataStoreService:GetDataStore("PassStore")

commands.remove = function(sender,arguments)
	if sender:GetRankInGroup(11635716) >= 254 then
		local userId = arguments[1]
		local success, errorMessage = pcall(function()
			passStore:RemoveAsync(userId)
		end)
		if not success then
			warn(errorMessage)
		end
	end
end

game.Players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(message,recipient)
		local splitString = message:split(" ")
		local slashCommand = splitString[1]
		local command = slashCommand:split(prefix)
		local commandName = command[2]
		print(commandName)

		if commands[commandName] then
			local arguments = {}
			for i = 2, #splitString, 1 do
			table.insert(arguments,splitString[i])
			end
			commands[commandName] (player,arguments)
		end
	end)
end)

So I think these are all good, but when I leave, thereā€™s no output from the script that adds me to the data store.

1 Like