Award Currency upon Event

Thank you for your help in advance, I am very new to scripting and doing my best to learn for the help i recieve.

I want to be able to award players with currency when an event is triggered. In this, when the mob reaches 0 HP, the player will be awarded a range of coins, for example 10-20 coins.

I am not sure how to call my leaderstats and make the number go up when the mob reaches 0 HP.

So far I have attempted calling the currency but because that was defined in a function I am not sure how to access it. I have provided the scripts for my leaderstats aka the Coins, and below that is my Health script for the mob. I have labeled where i believe the code needs to go that would give the player the random 10-20 coins.

local currencyName = "Coins"
local DataStore = game:GetService("DataStoreService") :GetDataStore("AdventureClickerStore")

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
	
	local ID = currencyName.."-"..player.UserId
	local savedData = nil
	
	pcall(function()
		savedData = DataStore:GetAsync(ID)
	end)
	
	if savedData ~= nil then
		currency.Value = savedData
		print("Player Loaded")
	else
		currency.Value = 100
		print("New Player")
	end
	
end)


--Saving when Player Leaves
game.Players.PlayerRemoving:Connect(function(player)
	local ID = currencyName.."-"..player.UserId
	DataStore:SetAsync(ID,player.leaderstats[currencyName].Value)
end)

--when game is ready to shut down
game:BindToClose(function()
	
	for i,player in pairs(game.Players:GetPlayers()) do
		if player then
			player:Kick("This game shut down")
		end
	end
	
	wait(3)
	
end)
local HP = "100"
local mob = game.Workspace.Mob
local damage = game.ReplicatedStorage.damage.Value
local clickDetector = mob.ClickDetector
local healthNumber = mob.healthbargui.barbackground.healthamount
local healthBar = mob.healthbargui.barbackground.bar
local healthValue = Instance.new("IntValue")
healthValue.Value = HP --Monster HP

healthNumber.Text = HP

healthValue:GetPropertyChangedSignal("Value"):Connect(function()
	healthNumber.Text = healthValue.Value
	print(healthNumber.Text, healthValue.Value)
end)

function onMouseClick()
	-- Subtract healthValue by Damage Amount and Change the healhBar Size
	healthValue.Value -= damage
	healthBar.Size -= UDim2.new(damage/HP, 0, 0, 0) --damage/whatever the monster HP is
	if healthValue.Value <= 0 then
		mob.ClickDetector.MaxActivationDistance = UDim2.new(0)
		print("stopped")
		healthNumber.Text = "0"
		
		--%%%%% I WANT TO AWARD PLAYERS WITH COINS HERE WHEN THE MOB REACHES 0 %%%%%
		
	end
	print(healthNumber.Text, healthValue.Value)
end

clickDetector.MouseClick:Connect(onMouseClick)

Thank you again for your help

The player is automatically passed as a parameter from the ClickDetector.

local clickDetector = script.Parent

function onMouseClick(player)
	-- Subtract healthValue by Damage Amount and Change the healhBar Size
	healthValue.Value -= damage
	healthBar.Size -= UDim2.new(damage/HP, 0, 0, 0) --damage/whatever the monster HP is
	if healthValue.Value <= 0 then
		mob.ClickDetector.MaxActivationDistance = UDim2.new(0)
		print("stopped")
		healthNumber.Text = "0"
		player.leaderstats.Coins += math.random(10, 20)
	end
	print(healthNumber.Text, healthValue.Value)
end

clickDetector.MouseClick:Connect(onMouseClick)

this was basically what i was looking for, all that was missing was .Value as shown below.

player.leaderstats.Coins.Value += math.random(10, 20)

Thank you for your help!