My goal is to ONLY fire my “beginCapturing” function if the conditions:
cpVal7 == “nil” or “axis”
axisVal7.Value == 0
allieVal1.Value > 1
My issue is that my conditions seem to be “met” when they supposedly shouldn’t be met, here’s an image of the output during my testing, always firing the “beginCapturing” function:
Here’s my function, containing the conditions:
allieVal7:GetPropertyChangedSignal("Value"):Connect(function()
task.wait(1.5)
print(axisVal7.Value, "axis val")
print(allieVal7.Value, "allies val")
if cpVal7.Value == "nil" or cpVal7.Value == "axis" and axisVal7.Value == 0 and allieVal1.Value > 1 then
print("beginning allies capture, there are this many axis in:", axisVal7.Value)
beginCapturing("allies", trench7)
elseif cpVal1.Value == "nil" or cpVal1.Value == "allies" and axisVal1.Value > 0 and allieVal1.Value == 0 then
print("beginning axis capture, there are this many ally in:", allieVal7.Value)
beginCapturing("axis", trench7)
end
end)
Context:
allieVal7’s value updates are based off of how many player’s on the “allies” team are in a specific area.
axisVal7 is the same but for the “axis” team.
cpVal17.Value == “nil” is always true right now, as the functionality to change it isn’t even in the game yet.
Note:
The “task.wait(1.5)” was added previous to the print statements to check if my issue was with the runtime, I don’t think anything changes when I increase or decrease this though
I’ve tried searching around, however, my problem is kind of specific and I haven’t got any responses elsewhere.
Alright, so I set my conditions up with brackets and now I’m having another issue…
Here’s what the current code looks like:
allieVal7:GetPropertyChangedSignal("Value"):Connect(function()
task.wait(1)
print(cpVal7.Value, axisVal7.Value, allieVal7.Value)
if (cpVal7.Value == "nil" or cpVal7.Value == "axis") and (axisVal7.Value == 0 and allieVal1.Value > 0) then
print(axisVal7.Value, "axis val")
print(allieVal7.Value, "allies val")
print("beginning allies capture, there are this many axis in:", axisVal7.Value)
beginCapturing("allies", trench7)
elseif (cpVal1.Value == "nil" or cpVal1.Value == "allies") and (axisVal1.Value > 0 and allieVal1.Value == 0) then
print(axisVal7.Value, "axis val")
print(allieVal7.Value, "allies val")
print("beginning axis capture, there are this many ally in:", allieVal7.Value)
beginCapturing("axis", trench7)
end
end)
That print statement above the conditions returned
cpVal17.Value as nil,
axisVal7.Value as 0,
allieVal7.Value as 1,
however, now the condition is meeting at all… opposite problem.