I need help with a script that is about currency. I am trying to make a shop where you spend currency on. Here's the leaderboard script, where my currency is called 'Coins':

local currencyName = "Coins"
local player = game.Players.LocalPlayer

game.Players.PlayerAdded:Connect(function(player)
	
	local folder = Instance.new("Folder")
	folder.Name = "leaderstats"
	folder.Parent = player
	
	local currency = Instance.new("IntValue")
	currency.Name = currencyName
	currency.Parent = folder
	
end)

And here's the buy button localscript:

local price = script.Parent.Parent.Price
local tools = game.ReplicatedStorage:WaitForChild("Tools")
local tool = script.Parent.Parent.ItemName
local player = script.Parent.Parent.Parent.Parent.Parent.Parent

script.Parent.MouseButton1Click:connect(function()
	if player.leaderstats:FindFirstChild("Coins").Value >= price.Value then 
		player.leaderstats:FindFirstChild("Coins").Value = player.leaderstats:FindFirstChild("Coins").Value - price.Value
		game.ReplicatedStorage.ShopBuy:FireServer(tool.Value)
	end
end)

The thing I want to do is to make the player lose the amount of currency needed for the tool, but for some reason the currency goes back to the exact amount when you kill a NPC... Here's the NPC script:

local Humanoid = script.Parent.Humanoid
function dead() 
local tag = Humanoid:findFirstChild("creator") 
if tag ~= nil then 
if tag.Value ~= nil then 
local Leaderstats = tag.Value:findFirstChild("leaderstats") 
if Leaderstats ~= nil then 
Leaderstats.Coins.Value = Leaderstats.Coins.Value + 5
wait(1)
script.Disabled = true
script.Parent:remove() 
end 
end 
end 
end 
Humanoid.Died:connect(dead) 

I would appreciate it if you could find a way to make it so the NPC gives the amount of currency (5) instead of returning to the currency you had before buying a tool...