Hello there.
I am trying to save tools with DataStore2. I’ve tried doing it myself, asked on the devforums, and I’ve also searched it up on YouTube to no avail.
Leaderstats Script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Votes = ReplicatedStorage:WaitForChild("VotesEnableDisable")
local DataStore2 = require(script.Parent.DataStore2)
DataStore2.Combine("DATA", "Wins", "Tools")
game:GetService("Players").PlayerAdded:Connect(function(Player)
local WinsStore = DataStore2("Wins", Player)
local ToolStore = DataStore2("Tools", Player)
local Tools = {}
game:GetService("ReplicatedStorage").PlayerAdded:FireAllClients()
Player.CharacterAdded:Connect(function(Character)
Character.Humanoid.Died:Connect(function()
ReplicatedStorage.PlayerDied:FireAllClients(Player.Name)
end)
end)
local Leaderstats = Instance.new("Folder")
Leaderstats.Name = "leaderstats"
local Wins = Instance.new("IntValue")
Wins.Name = "Wins"
Wins.Value = WinsStore:Get(0)
Wins.Parent = Leaderstats
local InRound = Instance.new("BoolValue")
InRound.Name = "InRound"
InRound.Parent = Player
local Afk = Instance.new("BoolValue")
Afk.Name = "Afk"
Afk.Parent = Player
WinsStore:OnUpdate(function(NewWins)
Wins.Value = NewWins
end)
ToolStore:OnUpdate(function(ToolName)
table.insert(Tools, 1, ToolName)
end)
Leaderstats.Parent = Player
for _, ToolName in pairs(Tools) do
ReplicatedStorage[ToolName]:Clone().Parent = Player.Backpack
end
end)
Shop Handler:
local BuyEvent = game:GetService("ReplicatedStorage"):WaitForChild("BuyItem")
local DataStore2 = require(script.Parent.DataStore2)
BuyEvent.OnServerEvent:Connect(function(Player, ToolName)
local ToolStore = DataStore2("Tools", Player)
local Tool = game:GetService("ServerStorage"):FindFirstChild(ToolName)
if Tool then
if Player.leaderstats.Wins.Value >= script[ToolName].Value and not Player.StarterGear:FindFirstChild(ToolName) then
Tool:Clone().Parent = Player.StarterGear
Tool:Clone().Parent = Player.Backpack
ToolStore:Set(ToolName, false)
end
else
Player:Kick("No exploiting please.")
end
end)
(This is a repost because my previous post got moderated.)

2 comments
save on leave and bindtoclose and make a table of the names of the tools and when u join loop through the table of the names and clone them in
@HappyTimIsHim I'm talking about DataStore2, a module, not normal DataStore.