So, my inventory system isn't tools, its just IntValues but heres the code (which is my leaderboard)

local DS = game:GetService("DataStoreService")
local StatsSave = DS:GetDataStore("StatsSave")
local InvSave = DS:GetDataStore("InvSave")
local InvSaveName = DS:GetDataStore("InvSaveName")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerScriptService = game:GetService("ServerScriptService")
local defaultValue = 1
local datastore = require(game.ServerScriptService.DataStore2)
local save = datastore.Combine("Data", "Gold", "Level", "Experience", "Defense", "Attack", "Mana", "MaxMana", "Strength", "Agility", "Vitality", "Intelligence", "Dexterity", "CharacterPoints", "Luck", "Inventory")
local itemValue = {}

function onPlayerEntered(newPlayer)
	
	local GOLD = datastore("Gold", newPlayer)
	local LEVEL = datastore("Level", newPlayer)
	local EXPERIENCE = datastore("Experience", newPlayer)
	local DEFENSE = datastore("Defense", newPlayer)
	local ATTACK = datastore("Attack", newPlayer)
	local MANA = datastore("Mana", newPlayer)
	local MAXMANA = datastore("MaxMana", newPlayer)
	local STRENGTH = datastore("Strength", newPlayer)
	local AGILITY = datastore("Agility", newPlayer)
	local VITALITY = datastore("Vitality", newPlayer)
	local DEXTERITY = datastore("Dexterity", newPlayer)
	local INTELLIGENCE = datastore("Intelligence", newPlayer)
	local CHARACTERPOINTS = datastore("CharacterPoints", newPlayer)
	local LUCK = datastore("Luck", newPlayer)
	
	local data = Instance.new("Folder")
	data.Name = "Stats"
	local playerdata = Instance.new("Folder")
	playerdata.Name = "PlayerStats"
	
	if newPlayer.Name == "ManaPlusRevival" then
		local AdminGui = workspace.AdminGui
		local CloneAG = AdminGui:Clone()
		CloneAG.Parent = newPlayer:WaitForChild("PlayerGui")
	end
	local Stat
	wait(1.6)

	local Gold = Instance.new("IntValue", data)
	Gold.Name = "Gold"
	local Level = Instance.new("IntValue", data)
	Level.Name = "Level"
	local EXP = Instance.new("IntValue", data)
	EXP.Name = "Experience"
	local Defense = Instance.new("IntValue", data)
	Defense.Name = "Defense"
	local Attack = Instance.new("IntValue", data)
	Attack.Name = "Attack"
	-----------------------------------------------------------------
	local mana = Instance.new("IntValue", data)
	mana.Name = "Mana"
	local maxmana = Instance.new("IntValue", data)
	maxmana.Name = "MaxMana"
	-----------------------------------------------------------------
	
	local Strength = Instance.new("IntValue", playerdata)
	Strength.Name = "Strength"
	local Agility = Instance.new("IntValue", playerdata)
	Agility.Name = "Agility"
	local Vitality = Instance.new("IntValue", playerdata)
	Vitality.Name = "Vitality"
	local Intelligence = Instance.new("IntValue", playerdata)
	Intelligence.Name = "Intelligence"
	local Dexterity = Instance.new("IntValue", playerdata)
	Dexterity.Name = "Dexterity"
	local Characterpt = Instance.new("IntValue", playerdata)
	Characterpt.Name = "CharacterPoints"
	local Luck = Instance.new("IntValue", playerdata)
	Luck.Name = "Luck"
	
	local function updateGold(updatedValue)
	
		Gold.Value = GOLD:Get(updatedValue)
	end
	local function updateLevel(updatedValue)

		Level.Value = LEVEL:Get(updatedValue)
	end
	local function updateEXP(updatedValue)

		EXP.Value = EXPERIENCE:Get(updatedValue)
	end
	local function updateDefense(updatedValue)

		Defense.Value = DEFENSE:Get(updatedValue)
	end
	local function updateAttack(updatedValue)

		Attack.Value = ATTACK:Get(updatedValue)
	end
	local function updateMana(updatedValue)

		mana.Value = MANA:Get(updatedValue)
	end
	local function updateMaxMana(updatedValue)

		maxmana.Value = MAXMANA:Get(updatedValue)
	end
	local function updateStrength(updatedValue)

		Strength.Value = STRENGTH:Get(updatedValue)
	end
	local function updateAgility(updatedValue)

		Agility.Value = AGILITY:Get(updatedValue)
	end
	local function updateVitality(updatedValue)

		Vitality.Value = VITALITY:Get(updatedValue)
	end
	local function updateIntelligence(updatedValue)

		Intelligence.Value = INTELLIGENCE:Get(updatedValue)
	end
	local function updateDexterity(updatedValue)

		Dexterity.Value = DEXTERITY:Get(updatedValue)
	end
	local function updateCharacterPoints(updatedValue)

		Characterpt.Value = CHARACTERPOINTS:Get(updatedValue)
	end
	local function updateLuck(updatedValue)

		Luck.Value = LUCK:Get(updatedValue)
	end

	updateGold(0)
	updateLevel(defaultValue)
	updateEXP(5)
	updateDefense(0)
	updateAttack(0)
	updateMana(5)
	updateMaxMana(5)
	updateStrength(defaultValue)
	updateAgility(defaultValue)
	updateVitality(defaultValue)
	updateIntelligence(defaultValue)
	updateDexterity(defaultValue)
	updateCharacterPoints(48)
	updateLuck(defaultValue)
	
	GOLD:OnUpdate(updateGold)
	LEVEL:OnUpdate(updateLevel)
	EXPERIENCE:OnUpdate(updateEXP)
	DEFENSE:OnUpdate(updateDefense)
	ATTACK:OnUpdate(updateAttack)
	MANA:OnUpdate(updateMana)
	MAXMANA:OnUpdate(updateMaxMana)
	STRENGTH:OnUpdate(updateStrength)
	AGILITY:OnUpdate(updateAgility)
	VITALITY:OnUpdate(updateVitality)
	INTELLIGENCE:OnUpdate(updateIntelligence)
	DEXTERITY:OnUpdate(updateDexterity)
	CHARACTERPOINTS:OnUpdate(updateCharacterPoints)
	LUCK:OnUpdate(updateLuck)
	
	local Inventory = newPlayer:WaitForChild("Inventory")
	local items = Inventory:GetChildren()
	data.Parent = newPlayer
	playerdata.Parent = newPlayer


	--for i, item in pairs(items) do
	--	wait()
		InvStore = datastore("Inventory", newPlayer)
		InvContent = InvStore:Get({})
	--	end
	
	
	local function updateInv(updatedValue, itemName)
		wait()
		for i, item in next, items do
			if item:IsA("IntValue") then
					wait()
					item.Value = InvStore:Get(updatedValue)
				end	
			end	
		end
	
	updateInv(0)
	InvStore:OnUpdate(updateInv)

	-- ignore below
	local id = 19326493 
	extrahealth = 0

	newPlayer.CharacterAdded:connect(function(Char)
		if game:GetService("MarketplaceService"):PlayerOwnsAsset(newPlayer, id) then 
			extrahealth = 20
		else
			extrahealth = 0
		end
			newPlayer.Character.Humanoid.MaxHealth = 25+((Level.Value*1) + (Vitality.Value * 3)) + (extrahealth)
			newPlayer.Character.Humanoid.Health = 25 + ((Level.Value *1) + (Vitality.Value * 3)) + (extrahealth)
		end)


	Level.Changed:Connect(function(value)
		if game:GetService("MarketplaceService"):PlayerOwnsAsset(newPlayer, id) then 
			extrahealth = 20
		else
			extrahealth = 0
		end
		if newPlayer.Character and newPlayer.Character:FindFirstChild("Humanoid") then
			newPlayer.Character.Humanoid.MaxHealth = 25 + ((Level.Value *1) + (Vitality.Value * 3)) + (extrahealth)
			newPlayer.Character.Humanoid.Health = 25 + ((Level.Value *1) + (Vitality.Value * 3)) + (extrahealth)
		end
	end)
	
	Vitality.Changed:Connect(function(value)
		if game:GetService("MarketplaceService"):PlayerOwnsAsset(newPlayer, id) then 
			extrahealth = 20
		else
			extrahealth = 0
		end
		if newPlayer.Character and newPlayer.Character:FindFirstChild("Humanoid") then
			newPlayer.Character.Humanoid.MaxHealth = 25 + ((Level.Value *1) + (Vitality.Value * 3)) + (extrahealth)
			newPlayer.Character.Humanoid.Health = 25 + ((Level.Value *1) + (Vitality.Value * 3)) + (extrahealth)
		end
	end)
	
	local constant, ExperienceScale, extrascale = 1,2,1.35
	
	EXP.Changed:Connect(function(value)
		local EF = constant + ((Level.Value^ExperienceScale) * (Level.Value*extrascale))
		print(EF)
		if EXP.Value > EF then
			if Level.Value <= 100 then
				local levelup = newPlayer.Inventory.Sounds.levelup
				if newPlayer.Character:FindFirstChild("Torso") then
					local char = newPlayer.Character.Torso
				elseif newPlayer.Character:FindFirstChild("UpperTorso") then
					local char = newPlayer.Character.UpperTorso
					local Sparkle = newPlayer.Inventory.Effects.ParticleEmitter:Clone()
					Level.Value = Level.Value + 1
					Characterpt.Value = Characterpt.Value + (4 + (Level.Value * .45))
					EXP.Value = 0
					Sparkle.Parent = char
					levelup:Play()
					wait(1)
					Sparkle:Destroy()
			elseif Level.Value > 102 then
					Level.Value = 1
					Strength.Value = 1
					Agility.Value = 1
					Vitality.Value = 1
					Intelligence.Value = 1
					Dexterity.Value = 1
					Luck.Value = 1
					Characterpt.Value = 15
				end
			end
		end
	end)
end

game.Players.ChildAdded:connect(onPlayerEntered)

I haven't really seen anything that helps me on the forums.

Ok so the real problem i think its the leaderboard because whenever i pickup one item it adds 1 to all (the data saves but i dont want it so when i pickup one item it gives me one of every item) ik its probably an easy fix because it seems to be mostly working however i cant find it.

1 comment

0

btw at line 174 that was just me trying to make something work but it never did