Hi, I just created a shop system with a remote event but when I click on the buy button the tool does not go inside my backpack…
Script:
local upgradeBought = rs:WaitForChild("remoteEvents").upgradeBought
upgradeBought.OnServerEvent:Connect(function(player, price)
local leaderstats = player:WaitForChild("leaderstats")
local cash = leaderstats:WaitForChild("money")
if cash.Value <= price then
cash.Value = cash.Value - price
local MaxwellTool = rs:WaitForChild("MaxwellTool"):Clone()
MaxwellTool.Parent = player.Backpack
end
end)
Why?
If anyone needs more info, I will glady give.
you are checking if the cash value is lower than the price
upgradeBought.OnServerEvent:Connect(function(player, price)
local leaderstats = player:WaitForChild("leaderstats")
local cash = leaderstats:WaitForChild("money")
if cash.Value >= price then --// replaced <= with >=
cash.Value -= price --// easier way to do this
local MaxwellTool = rs:WaitForChild("MaxwellTool"):Clone()
MaxwellTool.Parent = player.Backpack
end
end)