To more security, you can move your CustomCharacter and items into “ServerStorage”, so the exploiters can’t access it, the ServerStorage is a game Storage that only can be access within an Server Script, so they can’t access it because their exploits only work at a LocalScript! Anyway, you can learn how to use “RemoteEvent” and “RemoteFunction” to prevent it and one thing through, exploiters can still configure it BUT they only see that on their client, so the player on another client can’t see it! That mean you don’t need to worry about that, make sure focus on Remote in some important things ( Char, Items, Guns, Fire and Reloading, etc…) so your game will be security!
How large is your set?
Roblox now has a bit32 library now.
This is manipulating an actual bit though.
local bitStr = 1 --its a one
print(bit32.extract(bitStr,0,1)) -- prints 1
print(bit32.extract(bitStr,1,1)) -- prints 0
bitStr = bit32.replace(bitStr,1,1,1) -- made that 0 a 1
--side note documentation for ^ is missing v argument in function definition
print(bitStr) -- it is now 3, because 11 in binary is 11
This you are manipulating a number, one bit at a time. Your info is from right to left, because numbers.
Data position refers to the exponent of digit.
position 0 is 2^0 place
position 12 is 2^12 place
You can just use a real string and just put 0’s and 1’s as pseudo bits. I doubt you will reach the limit.
local ha = "happy helper" --random string
print(ha)
local tablet = table.pack(string.byte(ha,1,-1)) --converts to numerical value each char
print(tablet) -- its a table reference
local he = string.char(table.unpack(tablet)) --pokes back into string
print(he)
-- 48 is '0' and 49 is '1'
You would take and manipulate the table, it is sequential so each bit has an index = digit place (y is tablet[5])
This is much more intuitive (left to right).
The way I would go about saving the characters and bucks is I would create a folder within the player called “Characters”, and in it is a load of bool values, with the same name as each character.
Then, you make it so when a certain character is equipped, the game checks the folder within the player and sets the value to true for whatever character they have equipped. For example, if you have a “Noob Character” equipped, the bool value within the character for noob will be set to true once its equipped, and all other values will be set to false.
After this, you can use datastores to save all of the values, and make it so when you rejoin, the values load as they were in the previous game session. So when you join, the datastore would load the data and it would check the folder within the player to see if a character is equipped and if one is it would set the players character to that character.
For saving bucks, assuming its just an IntValue within leaderstats, you can use this script, but it may need tweaking a bit. Heres what I would do to save bucks.
local bindableEvent = Instance.new("BindableEvent")
local playersLeft = 0
game.Players.PlayerRemoving:connect(function(player)
playersLeft = playersLeft - 1
local datastore = game:GetService("DataStoreService"):GetDataStore(player.Name.."Stats")
local statstorage = player:FindFirstChild("leaderstats"):GetChildren()
for i = 1, #statstorage do
datastore:SetAsync(statstorage[i].Name, statstorage[i].Value)
print("saved data number "..i)
end
print("Stats successfully saved")
bindableEvent:Fire()
end)
game:BindToClose(function()
while playersLeft > 0 do
bindableEvent.Event:Wait()
end
end)
game.Players.PlayerAdded:connect(function(player)
local datastore = game:GetService("DataStoreService"):GetDataStore(player.Name.."Stats")
playersLeft = playersLeft + 1
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local bucks = Instance.new("IntValue")
bucks.Name = "Bucks"
bucks.Value = 0
bucks.Parent = leaderstats
player:WaitForChild("leaderstats")
wait(1)
local stats = player:FindFirstChild("leaderstats"):GetChildren()
for i = 1, #stats do
stats[i].Value = datastore:GetAsync(stats[i].Name)
print("stat numbber "..i.." has been found")
end
end)
This script should go in ServerScriptService. If you use this you may need to change around some stuff, but for the most part it should work in saving data found in the leaderstats folder when the player leaves and loading it when the player joins. The playersLeft counter and the BindableEvent is used to make sure there are no players left before a server shuts down, to ensure data gets saved if someone leaves the game and a server becomes empty.
I hope this helped, you can edit the script to also save the characters in the way I stated above. If I’ve made any mistakes then I’d be grateful if someone corrected me.
I have actually used RemoteEvents and RemoteFunctions a lot in this game so far haha, I had just assumed you meant store the character in the player itself, which obviously isn’t good. The items are already stored in ReplicatedStorage, and from there you retrieve the item from there and set it on your character when you purchase it. but do you think ServerStorage would be a good idea?
My set is a total of 26 items, 8 torsos, 8 hats, 8 materials, and 2 heads. I don’t know if that really changes anything but it isn’t a multiple of 8, so perhaps?
Yes, but actually Local Script can’t access Server Storage so it would be more security because exploits only working like a Local Script, only Server Script can access it, it would be helpful to prevent hackers!
Smart idea! I’ll bring the hats to ServerStorage.
You can’t save data across game “universes” but you CAN across different places within the same game “universe”.
NOTICE: I previously mispleledand wrote can instead can’t for the following:
You can’t save data across game “universes”
Apologies for any confusion and thanks to @XxELECTROFUSIONxX for pointing it out!