local CraftingDatastore = game:GetService("DataStoreService"):GetDataStore("Crafting")
-- toxic
local function save(plr)
local Added = plr.PlayerGui.CraftingUI.Main:FindFirstChild("ToxicGlove").Rarities:FindFirstChild("Toxic").Added
local Completed = plr.PlayerGui.CraftingUI.Main:FindFirstChild("ToxicGlove").Rarities:FindFirstChild("Toxic").Completed
print(Added.Value)
print(Completed.Value)
local ToxicDataFolder = {}
ToxicDataFolder["Added"] = Added.Value
ToxicDataFolder["Completed"] = Completed.Value
local success,errorMsg = pcall(function()
CraftingDatastore:SetAsync(plr.UserId,ToxicDataFolder)
end)
if success then
print("Data saved!")
else
print("There was an error while saving data")
warn(errorMsg)
end
end
local function load(plr)
local Added = plr.PlayerGui.CraftingUI.Main:FindFirstChild("ToxicGlove").Rarities:FindFirstChild("Toxic").Added
local Completed = plr.PlayerGui.CraftingUI.Main:FindFirstChild("ToxicGlove").Rarities:FindFirstChild("Toxic").Completed
print(Added.Value)
print(Completed.Value)
local data = CraftingDatastore:GetAsync(plr.UserId)
if data then
Added.Value = data["Added"]
Completed.Value = data["Completed"]
else
print("No data exists/New player")
return
end
end
game.Players.PlayerAdded:Connect(function(plr)
load(plr)
end)
game:BindToClose(function()
for _, plr in pairs(game.Players:GetPlayers()) do
save(plr)
end
end)
no, you just have to have the values on the server already, either send them by a remoteevent if its a simple value, but if its a save its better you handle this on the server already so you cant exploit it