My Automatic shifting system seems to only work partly

I am trying to achieve automatic transmission and i though the method i thought was simple but apparently it only works one way? The Rpm is dynamically changing and all im trying to do is to do upshift and downshift. The upshift and downshift values are of ranges that are RPM and both have values. only downshift works and i am unsure why its like that. am i missing something in this? i would think it would be very simple. UPshift is around 11500 and the max rpm goes up to 12025 and Downshift is at 5000. EDIT: MAXGEARS is 4

if RPM > UpShiftRPM then
 CurrentGear = math.clamp(CurrentGear + 1,1,Max_Gears)
 print("UP_SHIFT")
end

if RPM < DownShiftRPM then
 CurrentGear = math.clamp(CurrentGear + -1,1,Max_Gears)
 print("DOWN_SHIFT")
end

Hello, I was analyzing the first part of the script that says

if the numbers in the first part are both 1,1 should the second part be the same by -1,-1?

so whats happening is i want it to be the minimum of 1 but in the math it adds 1 to currentgear wich is just 1. downshifts work fine its just when i go to a high rpm it will not add when its out of range for the downshift.

The first argument in math.clamp is the variable, the second and third and the lower and upper bounds. He uses it to make sure CurrentGear doesn’t go any less than 1 or any higher than Max_Gears.

1 Like

When it up-shifts does the RPM drop to a point below the down-shift range? That might cause some kind of feedback loop where it could down-shift immediately after an up-shift.

no currently it dosnt change anything in my vehicle. wich include rpm.

I think this actually might be a bug i think because my other scripts broke and it used a similar method but for other stuff. but i think its more likely a scripting error and i some how cant find a fix.

I found out it was downshifting a lot but even when i disable that if statement the upshift if statement seems to not work still. and i checked and it is getting RPM and UpshiftRPM value. am i doing something wrong. how could i implement a delay system so when it shifts it dose it once and it has a cool down?

i found out solution apparently the max rpm was too high even tho the rpm was reaching that high