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
--<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)
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.