Hi everyone, new scripter here with a question. This if statement seems to always jump to “else” even if the conditions I stated at the top are correct (I checked the values in Explorer)
storage.Lanes.PassScanner.OnServerEvent:Connect(function(player, lane)
local char = script.Parent
if char.QueuePosition.Value == 0 and char.LaneAssignment.Value == lane then
else print("Aborted") end
end)
If I replace the use of == lane with == 1, the correct value, it works just fine. Why can’t I use this variable in the if statement?
--pass through the scanner
storage.Lanes.PassScanner.OnServerEvent:Connect(function(player, lane)
print("Got the pass signal " .. "for lane " .. lane .. ".")
local char = script.Parent
local test = lane
print(char.LaneAssignment.Value .. lane)
if char.QueuePosition.Value == 0 and char.LaneAssignment.Value == lane then
print("WORKING!")
local target = lanes[lane].PostScannerTarget
local officer = player.Name
game:GetService("Chat"):Chat(workspace[officer].Head, "You may pass through.", Enum.ChatColor.White)
wait(1)
followPath(target)
game:GetService("Chat"):Chat(script.Parent.Head, "Okay, coming through!", Enum.ChatColor.White)
wait(3)
game:GetService("Chat"):Chat(script.Parent.Head, "That wasn't so bad...", Enum.ChatColor.White)
wait(3)
char:Destroy()
lanes[lane].PaxInService.Value = false
else print(char.LaneAssignment.Value .. lane) end
-- path.Blocked:Connect(function(blockedWpIdx)
-- if blockedWpIdx > wpIdx then
-- followPath(target)
-- end
-- end)
end)
The if statement works with the QueuePosition part that’s why I initially cut it out-
I only get problems with the use of the lane variable… replacing it with “1” literally fixes it so I don’t understand why a variable equaling 1 would not do the same thing.
Okay strangely enough I made the origin of the variable lane’s value (1) to be another number value which is equal to 1 and it worked.
Essentially I went from comparing a 1 which was a name of a ScreenGUI and a 1 from a number value to comparing a 1 from a number value and a 1 from a number value.
Can someone explain this? Is a number in the name of a ScreenGUI different from a number in the value of a number value?