How can I put a tool into the players hot bar

Hi,

I have made some tools and put them into the server storage. and I want it so when someone clicks a part or something it charges them gold and if they have enough then they lose the gold and get the tool into their hot bar. I tried searching google and the dev forum but I did not find anything. here is the script I had for the gold leaderboard, I put it in sever script service (I have 2 types of cash)

function onPlayerEntered(player)
local stats = Instance.new(“Folder”)
stats.Name = “leaderstats”
stats.Parent = player

local cash = Instance.new("IntValue")
cash.Name = "Gold"
cash.Value = 0
cash.Parent = stats

local cash = Instance.new("IntValue")
cash.Name = "Alexandrite"
cash.Value = 0
cash.Parent = stats

end

game.Players.ChildAdded:Connect(onPlayerEntered)

Thank you!

I would use the .MouseClick event of the ClickDetector. Next, I would check if the player has enough gold. If so, charge them then give them the tool.

I dont really know how to script, so I would like some scripts and tell me where to put them.

Use the humanoid:EquipTool() function in a server script. You need to parent it to workspace first then starter pack

My bad if your server script is in your tool you need to parent it to workspace then starter pack*

You should move the tool into replicated storage

--<Server Side
local function Purchase(Plr, TargetItem)
    local PlrGold = Plr:WaitForChild("leaderstats"):WaitForChild("Gold");
        if(PlrGold.Value < ItemPrice)then return end; --< If they don't have enough gold, do nothing
PlrGold.Value-=ItemPrice; --<Charge Price
local Tool = TargetItem:Clone(); --<Clone The Tool
    Tool.Parent = Plr:WaitForChild("Backpack"); --< Will show on the players "hot bar"
end;

You should use game.Players.PlayerAdded:Connect(onPlayerEntered)

I can not spoon-feed you code. As it says here,

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

how do I choose what tool it is, and how much it costs? I can’t figure it out