I do not recommend saving the crates or any important data such as "money" (as an example) on the client side. Instead of saving crucial data via client, save it on the server side. Use the server to store and manage data and use the client to display that data.
Since you are using crates, create a remote event that calls to open the create. When that remote event gets fired the event sends the player's name as the very first parameter. You can use it to locate the player.
Example:
script.RemoteEvent.OnServerEvent:connect(function(plr)
end)
So the server randomly chooses an item from the crate (if this is how your crate system works). It can then use the player's name to put it into their inventory. I recommend saving these items into the server's storage.
Example:
randomItem = {"Gun", "Knife", "Dollar"}
script.RemoteEvent.OnServerEvent:connect(function(plr)
local givenItem = randomItem[math.random(1, 3)]
local clonedItem = game.ServerStorage[givenItem]:Clone()
clonedItem.Parent = game.Players[plr].StarterGear
end)
Hope this helps; if you got any questions please contact me. ;)
4 comments
Make the remote event have a certain parameter, almost like a password. I.e. remoteevent:FireServer("p@$$w0Rd") then in the server script have it check to see if they second field is the correct password.
But can't they read the scripts?
No they can only debug local scripts
It takes lots of effort.