>= statement not working

Hello developers! Me and a friend are creating a tycoon to learn to script and have come across an issue in our script.

We are trying to make a purchase that goes off when you step on a plate in the tycoon. For some reason even when my cash is more than 50 it says “not enough money” even though it is enough. It always says “not enough money” even when it is over 50.

Capture (3)
How can we resolve this? Our code:

baseplate = script.Parent
debounce = false

baseplate.Touched:Connect(function(hit)
    local hum = hit.Parent:FindFirstChild("Humanoid")
    print("hi")
    if hum ~= nil and debounce == false then
        local player = game.Players:GetPlayerFromCharacter(hit.Parent)
        if player.Team == "Purple Tycoon" then
            if player.leaderstats.Cash.Value.Value >= 50 then
                player.leaderstats.Cash.Value = player.leaderstats.Cash.Value - 50
                local autodropper = workspace.Folder["F1 dropper 1"]:Clone()
                autodropper.Parent = workspace.Objectscreated
                autodropper:SetPrimaryPartCFrame(CFrame.new(Vector3.new(-136.612, 501.442, -505.756)))
            end
            else
                print("not enough money")
                print(player.leaderstats.Cash.Value)
        end
    end
end)

You end the if statement before saying “not enough money,” so that will print regardless of the amount of money you have.

I think you’re looking for:

if player.leaderstats.Cash.Value >= 50 then
    --you already wrote this
else
    print("not enough money")
    print(player.leaderstats.Cash.Value)
end
1 Like

What’s going on here? Two Values? I think there should only be one. Considering how you went about it in the rest of your script?

Such as here :

And here :

1 Like