so im making a td game, im rewritting the upgrading system because the old one sucks, but i keep getting the error:
14:53:29.197 ServerScriptService.ServerTowers:33: attempt to compare string <= number - Server - ServerTowers:33
14:53:29.197 Stack Begin - Studio
14:53:29.198 Script 'ServerScriptService.ServerTowers', Line 33 - Studio - ServerTowers:33
14:53:29.198 Stack End - Studio
this is the code:
event3.OnServerInvoke = function(player,tower,level,towerpos,towername,towerpart)
if player.stats.Cash.Value >= tostring(towercosts.Data[towername][level]) then
local oldtower = tower
local newtower = towermodels[towername][level]:Clone()
newtower.Parent = towerpart
newtower:MoveTo(towerpos)
for i,v in pairs(tower:GetDescendants()) do
if v:IsA("Part") or v:IsA("MeshPart") then
v.Anchored = true
v.CanCollide = false
v.Transparency = 1
end
end
newtower.Name = "TowerModel"
oldtower.Name = "OldTowerModel"..math.random(1,1000)
oldtower.Parent = workspace.OldTowerModels
newtower.TowerGeneral.Disabled = false
newtower.Script.Disabled = false
newtower.TowerGeneral.GuiDetector.Disabled = false
if oldtower:FindFirstChild("Humanoid") then oldtower.Humanoid:Destroy() end
for i,v in pairs(oldtower:GetDescendants()) do
if v:IsA("Script") then
v.Disabled = true
end
end
player.stats.Cash.Value -= towercosts.Data[towername][tostring(level)]
oldtower:Destroy()
return newtower
else
game.ReplicatedStorage.Notify:FireClient(player,"You don't have enough cash to upgrade that!",4)
end
end
and this is the line that is throwing the error:
if player.stats.Cash.Value >= tostring(towercosts.Data[towername][level]) then
towercosts is a module that contains how much towers cost to upgrande and place, towername is the name of the tower, and level is the level its trying to upgrade to

. It’s sometimes hard to really see your own work (which is why most pro companys use pair programming). You often only see what you think should be there, or what you want to be there. Need to teach yourself to read code like you didn’t write it, which is hard.