I have a local script that compares the players “cash” and the cost of an upgrade, and if the player can afford the upgrade, a remote event is triggered. The code usually works, but when the players cash is to high (usually at least double the cost of the upgrade) the code will claim the cost is higher.
The local script:
local module = require(script.ModuleScript)
local player = game.Players.LocalPlayer
local mainframe = game.Workspace:WaitForChild("PotatoFarmUpgrades").SurfaceGui.MainFrame
de1 = false
mainframe.ValueFrame.TextButton.MouseButton1Click:Connect(function()
if player:WaitForChild("TrueStats").TruePotatoes.Value >= player:WaitForChild("TrueStats").ValueCost.Value then
de1 = true
game.Workspace.Upgrade.RemoteEvent:FireServer("UpgradeValue")
wait(1)
de1 = false
else
print(player.TrueStats.TruePotatoes.Value, player.TrueStats.ValueCost.Value)
end
end)
If the cost is higher than the “potatoes” Value, the number of potatoes and cost are printed.
Examples of failed comparisons where the potato value is clearly larger:
12631 and 4800
136548 and 54675
What do I do?