Tool not going into the backpack

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)
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.