Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is If statement is being ignored?

Asked by 3 years ago
Edited 3 years ago

I have a very simple question, why my If statement is not working after -If Jugador ~= nil then-, after this the next If statement (if Jugador.Valor.Value > 999 then) is not working but if I put another code for example Jugador.Valor.Value = Jugador. Valor.Value - 1000 without the -If Jugador.Valor.Value > 999 then- it works.

PD: The output shows no errors or warnings.

local upgrader = workspace.Upgraders.Upgrader1
local bean = upgrader.Bean

script.Parent.Touched:Connect(function(Part)
    if Part.Parent:FindFirstChild("Humanoid") then
        local Jugador = game.Players:GetPlayerFromCharacter(Part.Parent)
        if Jugador ~= nil then
            if Jugador.Valor.Value > 999 then
                Jugador.Valor.Value = Jugador.Valor.Value - 1000
                upgrader.Transparency = 0
                upgrader.CanCollide = true
                bean.Transparency = 0.7 
                workspace.Upgraders.Upgrader1.Bean.upgradeador1.Disabled = false
            end
        end
    end
end)

1 answer

Log in to vote
0
Answered by 3 years ago

Have you made sure to add the Valor inside of the Player? If so, has it been programmed to go over 999? If not, then it won't trigger.

0
Yeah, all players have the Valor.Value inside of them, also that value can go over 999, if I put another code like Jugador.Valor.Value = Jugador.Valor.Value - 100 for example, WITHOUT the If statement, it works AssassinJackCCP 0 — 3y
0
Sorry for the late reply, but what kind of script is this? Dothemariobowp9 24 — 3y
Ad

Answer this question