Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why is If statement is being ignored?

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

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.

2 comments

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

0

Sorry for the late reply, but what kind of script is this?

This discussion is preserved as it was. New answers, comments, and votes are closed.