this is a localscript that fires a remote that charges the player $300 for a baseball bat however it only works once then it doesn't work the second time and comes up with an error.Also my guy had enough money
script.Parent.MouseButton1Click:Connect(function()
local plr=game.Players.LocalPlayer
local cash=plr.Data.Wallet
if cash.Value>=300 then
local event=game.ReplicatedStorage.backpack
event:FireServer("Baseball Bat",300)
script.Parent.Parent.Visible=false
end
end)
The error is on the remote script's line 8
game.ReplicatedStorage.backpack.OnServerEvent:connect(function(plr,Message,cost)
local pack=game.ServerStorage.Tools:FindFirstChild(Message)
local cash=plr.Data.Wallet
cash.Value=cash.Value-cost
pack:Clone()
pack.Parent=plr.Backpack
end)

2 comments
Now its saying "Infinite yield possible on 'ServerStorage.Tools:WaitForChild("Chicken Leg")'"
Well hopefully Chicken Leg is actually there. But you can add an extra parameter for a yeild counter and if it never finds the item within a certain amount of time just cancel the purchase. Ex: local pack = serverStorage.Tools:WaitForChild(Message, 10) if not pack then print("Couldn't locate item. Canceling purchase.") return end)