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

if then statements?

How would I make an if then statement that checks if the localplayers points are equal to or greater than 120?

I tried this:

script.Parent.MouseButton1Down:connect(function(GUI)
	if game.Players.LocalPlayer.leaderstats.Points >= 120 then
		game.Players.LocalPlayer.leaderstats.Points.Value = game.Players.LocalPlayer.leaderstats.Points.Value - 120
		game.Players.LocalPlayer.sONE.Value = true
		script.Parent.Parent.psorisf.TextLabel.Text = "Purchase complete!"
		wait(2)
		script.Parent.Parent.psorisf.TextLabel.Text = ""
	elseif game.Players.LocalPlayer.sONE.Value < 120 then
		script.Parent.Parent.psorisf.TextLabel.Text = "Insufficient funds!"
		wait(2)
		script.Parent.Parent.psorisf.TextLabel.Text = ""
	end
end)

But it says in the output tried to do arithmetic on a player value or something, I need it to check if it IS EQUAL to or greater than 120, not make it equal to or greater than 120. Is there some operator like >==? I know that isn't but is there something like that?

1 answer

✓ Accepted answer
script.Parent.MouseButton1Down:connect(function(GUI)
    if game.Players.LocalPlayer.leaderstats.Points.Value >= 120 then
        game.Players.LocalPlayer.leaderstats.Points.Value = game.Players.LocalPlayer.leaderstats.Points.Value - 120
        game.Players.LocalPlayer.sONE.Value = true
        script.Parent.Parent.psorisf.TextLabel.Text = "Purchase complete!"
        wait(2)
        script.Parent.Parent.psorisf.TextLabel.Text = ""
    elseif game.Players.LocalPlayer.sONE.Value < 120 then
        script.Parent.Parent.psorisf.TextLabel.Text = "Insufficient funds!"
        wait(2)
        script.Parent.Parent.psorisf.TextLabel.Text = ""
    end
end)

What you did wrong is on line 2, you for got the ".Value" next to Points.

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