Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Would a leaderstats Script be secure in Filtering Enabled?

##Normal Stats Script

This would be a normal leaderstats script:

--\\ Services
local players = game:GetService("Players")

players.PlayerAdded:Connect(function(player)
	local stats = Instance.new("Folder")
	stats.Name = "leaderstats"
	stats.Parent = player

	local randomValue = Instance.new("StringValue")
	randomValue.Name = "Random Value" 
	randomValue.Value = "oof"
	randomValue.Parent = stats
end)

##What Is My Question?

I noticed, is this really the best way to make stats? Is there an even more secure(and probably optimized way). I am saying if there is a much more secure way to approach this because it doesn't even use any Remotes. I am just curious to see if there are any different (and probably better) approaches.

Thank you for helping me in advance

2 answers

you should make a folder in server storage call it stats then do this in your script you willalso have to change 2 values when changing the leaderstats and there can not be a wait() between the two lines also they should look like this player.leaderstats["Random Value"].Value = "Hi"

game.ServerStorage.Stats[player.Name]["Random Value"].Value = "Hi"

local players = game:GetService("Players")
 
players.PlayerAdded:Connect(function(player)
local Folder = Instance.new("Folder", game.ServerStorage.Stats)
Folder.Name = player.Name
    local stats = Instance.new("Folder", game.ServerStorage.Stats[player.Name])
    stats.Name = "leaderstats"
   
 
	    local randomValue = Instance.new("StringValue", stats)--same thing as randomValue.Parent = stats
	    randomValue.Name = "Random Value"
	    randomValue.Value = "oof"
    	  
end)

while true do
wait()
for i,v in pairs(players:GetChildren()) do
if v.leaderstats["Random Value"].Value ~= game.ServerStorage.Stats[v.Name]["Random Value"] then
-- for this ill just kick them
kick(v, "Stop Hacking")
end
end

6 comments

0

this may not work i didnt test it and it may glich

0

Learn to indent your code! It makes reading it much easier

0

You should never parent a new Instance before changing its properties. It is a good optimizing technique to simply make the instance(without its parent), then, change its properties, finally, you should parent

0

If I were to change my string value(randomValue) and make it an IntValue and name it to Level. The level would change. What would I do in that situation?

0

the same thing just change the name an values

0

I know that. But, what I mean is this: if the level would change its value after killing some mobs, what would I do in that situation? The value won't be consistent all the time

This would be secure if you turned on FilteringEnabled, only if you don't make a RemoteEvent that lets the client change the folder. I don't recommend that you allow the client to change the folder, because then exploiters can just fire the remote and cheat. You could make add an extra argument for a password, but that doesn't really help much since exploiters can just listen for every time the remote is fired then copy and paste the arguments. If you really wanted the client to change the folder, then you can make a remote that does something specific that changes the folder. An example: Imagine your folder had a value inside called Knockouts. Making a remote for increasing the value wouldn't be secure at all, but making a remote that shoots a bullet at a position is very secure, because if an exploiter fired the remote, they would just be playing normally, just by using scripts.

Hope this helped!

PS: I don't really think there's a better way to do it.

This discussion is preserved as it was. New answers, comments, and votes are closed.