I have to, unit is defined in it. —
You are trying to print out both returns of the attributes, and nothing prints out in the output (that at least matches the lines from the screenshots), please just try to print out a random string within the for loop to so if it even executes, there is nothing inherently wrong with your if statement.
what do you mean? it prints exactly what i told it to
the only things that dont print is the stuff in the tonumber if statement
From what I’m seeing based on the screenshots, the lines do not match. Line 19 is the if statement itself (thus no printing), and line 28 is not visible from the screenshots. The for loop itself probably doesn’t execute and that’s why the if statement won’t run.
for the last time the loop works
What type is the Nation attribute, and what are the values?
can you fire end turn after the loop instead if that doesn’t break anything
if they were any other type it would have already been solved by my suggestion of using tonumber(type)
wait i think you might of helped me here, it is a number attribute so i could use tostring
I do not know if tonumber will solve the problem, but, based on the initial screenshot, this:
This syntax is potentially not what are you are trying to achieve, you are using tonumber on the entire statement, and not to each of the attributes.
if tonumber(unit:GetAttribute("Nation")) == tonumber(player:GetAttribute("Nation")) then
Was probably what you were trying to do.
i fixed it using tostring
weird if syntax was the issue it would have errored…
What I meant by that is that it wouldn’t serve the same purpose of what you were trying to get in the first place, thus being wrong. You can try out the line I sent and see if that works too.
Edit: Also, the initial problem might have been because :GetAttribute() returns a tuple, and one of the tuple’s returns might have no equaled, thus causing this issue. So comparing the first return which is the value fixed this issue (because tonumber or tostring both deal with the first argument).
I understood what you said, what I meant is if that’s the case it would have errored if it was wrong.
the entire problem was using tonumber instead of tostring
I didn’t mean a Lua syntax error, but the syntax was not executing the way that was intended (wrongly), that’s what I meant, though it’s not relevant anymore as this thread is getting too large.
I just like trying to clearing up the confusion, yeah, lets stop talking, its getting too big.