Hello!
Problem: DataStore is not saving the Tools of players when they die/leave the game, and is also not saving the Leaderstats when a player leaves and returns. Also, when a player purchases the Tools, it continues to clone infinitely until a player dies, at which point the Tools disappear from the Backpack, but remain inside StarterPack.
There is a Folder inside** StarterPack** named "Inventory" that has BoolValues: HasM9, HasPistol, HasAK, etc.
These BoolValues are turned into True when a Player purchases an item from the Shop: SHOP Script:
--Shop Purchase Script Above
if plr.leaderstats.Points.Value >= amount then
tool:Clone().Parent = plr.Backpack
tool:Clone().Parent = plr.StarterGear
plr.leaderstats.Points.Value = plr.leaderstats.Points.Value - amount
plr.Backpack.Inventory.HasM9.Value = true
else
--Shop Purchase Script Below
Inside of ServerScriptStorage I have the following Module Script as my DataStore Script DataStore Script:
https://pastebin.com/AjGkFyi2 (my script goes way past the 10,000 character limit, including it as an external link.)
As a descendant of this Module Script is a short Script:
require(script.Parent)
Now, to ensure that the purchased Tools are given to the player is a Local Script inside StarterPlayer - StarterPlayerScripts named ToolGiverCheck.
ToolGiverCheck Script:
local player = script.Parent.Parent
local rs = game:GetService("ReplicatedStorage")
while wait(1) do
if player.Backpack.Inventory.HasM9.Value == true then
local m9 = rs.M9:Clone()
m9.Parent = player.Backpack
end
if player.Backpack.Inventory.HasPistol.Value == true then
local pistol = rs.Pistol:Clone()
pistol.Parent = player.Backpack
end
if player.Backpack.Inventory.HasM4.Value == true then
local m4 = rs.M4:Clone()
m4.Parent = player.Backpack
end
if player.Backpack.Inventory.HasShotgun.Value == true then
local shotgun = rs.Shotgun:Clone()
shotgun.Parent = player.Backpack
end
if player.Backpack.Inventory.HasSuperball.Value == true then
local superball = rs.Superball:Clone()
superball.Parent = player.Backpack
end
if player.Backpack.Inventory.HasRocketLauncher.Value == true then
local rocketlauncher = rs.RocketLauncher:Clone()
rocketlauncher.Parent = player.Backpack
end
if player.Backpack.Inventory.HasGoldenGun.Value == true then
local goldengun = rs.GoldenGun:Clone()
goldengun.Parent = player.Backpack
end
if player.Backpack.Inventory.HasBombthrower.Value == true then
local bombthrower = rs.BombThrower:Clone()
bombthrower.Parent = player.Backpack
end
if player.Backpack.Inventory.HasAK.Value == true then
local ak = rs.AK:Clone()
ak.Parent = player.Backpack
end
if player.Backpack.Inventory.HasFireball.Value == true then
local fireball = rs.Fireball:Clone()
fireball.Parent = player.Backpack
end
end
Summarized Question: How do I fix my scripts so that the Player is able to retain their Tools after death, and that their Leaderstats save when they leave/return to the game?
I owe abnotaddable a big thank you for all the help that's been provided so far. :) I know this script is close to being working, just need a bit more help. Thank you so much in advance to everyone who's given/will give assistance.

4 comments
I think I know why its infinitely cloning
I will do this and make sure that it works with fe as well
I have wrote the the data stores, but I had to use pastebin
Commented in response to your answer with follow-up questions! :) Thank you again!