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

if then statements?

Asked by 10 years ago

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

Log in to vote
0
Answered by
Hybric 271 Moderation Voter
10 years ago
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.

Ad

Answer this question