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

Why does my script print "equal" when it shouldn't do that?

Asked by
JoneXI 51
3 years ago

Hello, I have a problem, here is my script:

for i,v in pairs(playing) do
    for _,x in pairs(playing) do
        if v.Votes.Value == x.Votes.Value then
            if v.Votes.Value ~= 0 and x.Votes.Value ~= 0 then
                print("equal")
                tie = true
            end
        end 
    end
end 

My problem is that when there are 3 players, one of them has 1 vote and others have 0 it still prints equal once and tie sets to true and I cant figure out why it does that... Any ideas?

Thank you.

1 answer

Log in to vote
1
Answered by 3 years ago

See if this helps:

for i,v in pairs(playing) do
    for _,x in pairs(playing) do
    if v.Votes.Value == x.Votes.Value and v.Name ~= x.Name  then
        if v.Votes.Value ~= 0 and x.Votes.Value ~= 0 then
            if v.Votes.Value ~= 0 and x.Votes.Value ~= 0 then
            tie = true
            end
        end
    end
end

It kind of happened because v and x are the same thing (I think) and the script I have given will help.

1
Oh, yea that worked, my brain isn't working today lol, thanks JoneXI 51 — 3y
Ad

Answer this question