How can I put a tool into the players hot bar


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 =“Folder”)
stats.Name = “leaderstats”
stats.Parent = player

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

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



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.

1 Like

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"

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