hi people so i got an issue again
local lastSpeed = plr.Stats.Movespeed.Value --16
local lastPriority = 0
print(AddedSpeeds)
for index,value in pairs(AddedSpeeds) do
if value.Priority > lastPriority then
lastSpeed = value.Speed
lastPriority = value.Priority
end
if value.Speed <=lastSpeed and value.Priority <lastPriority then
lastSpeed = value.Speed
end
end
print(lastSpeed)
this is supposed to returning either the lowest speed or highest priority right
for reference here’s what addedspeeds is equal to:
but for some reason the last speed is set to 16 instead of 36.5?
i’ve ran this code to simulate the issue on a blank baseplate:
local dictionary = {
["Base"] = {
Speed = 0;
Priority = 0;
},
["Test"] = {
Speed = 30;
Priority = 2;
}
}
local lastPriority = 0
local lastSpeed = 16
print(dictionary)
for index,value in pairs(dictionary) do
if value.Priority > lastPriority then
lastSpeed = value.Speed
lastPriority = value.Priority
end
if value.Speed <=lastSpeed and value.Priority <lastPriority then
lastSpeed = value.Speed
end
end
print(lastSpeed)
however that code returns 30 which is the correct one (higher priority)
i must be missing something in the first code to cause this issue any help is appreciated!
edit - sent a wrong code on the second thingy corrected