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

Expected 'then' when parsing if statement, got '=' help me?

Asked by 4 years ago
Edited 4 years ago
game.Players.PlayerAdded:Connect(function(plr)


local sd = math.random()

if sd = 0 then
    print("NotHaoBorn")

    if sd = 1 then
        print("HaoBorn")
    end
end


end))`

2 answers

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

When writing if statements, you're required to have two '=' signs.

So, all you need to do is

game.Players.PlayerAdded:Connect(function()
    local sd = math.random()
    if sd == 0 then
        print("NotHaoBorn")
        if sd == 1 then
            print("sd is 1")
        end
    end
end)

Let me know if you have any questions.

Ad
Log in to vote
0
Answered by 4 years ago

In an if statement, putting "==" will check if sd is 0. if you put "~=", it will check if sd is not 0. If you just put an equals sign, it will not work.

Answer this question