Weird script bug

Ok, so I have a fair amount of experience in roblox studio and by no means am I new…

I have no idea why this elseif statement does not work, when I say does not work, I mean it doesn’t output true.

elseif (tick()-players[plr]) <= 1 then...
Note: (tick()-players[plr]) prints 0.58235…etc, I have type checked and it is also a number type

The rest of the script literally would have nothing to do with this as it’s a simple debounce check, if your interested yes this is done on the server (just wanted to point that out)

Ima have to leave so please just provide any information, I know i’m providing limited info, I will provide as much as I can if necessary…

Thanks in advance.

Ok, i’m back after screwing around a little I think the issue lies with this (tick()-players[plr])
This was working before, but after adding a debounce it stopped working for some reason (I’m positive the reason isn’t to do with the debounce since when I claimed to be screwing around I actually swapped the statement in my question to elseif 0.5 <= 1 then and it did return true so I at least know it’s not do with my debounce nor a engine bug)

I think having more info on the if statement as a whole might provide some insight. Is it possible that the first condition (in this case, ‘something’) is true and therefore the second condition in the elseif is never reached?

if (something) then -- is something true here?
    -- this code might be running
elseif (tick()-players[plr]) <= 1 then
    return true -- elseif will never run if the first condition in the if statement was true
end
1 Like

I understand that my bad, sorry I was in a rush when typing this…

if (tick()-players[plr]) >= 1.1 then
    --This bit runs everytime
elseif (tick()-players[plr]) <= 1 then
    -- this for some reason does not run

The things I’ve tried were swapping the arguements seeing if maybe the top if statement was the issue, but this was not the case…

I also tried putting a decimal point to the elseif like so:
elseif (tick()-players[plr]) <= 1.0 then
This too did not yield any results…

EDIT: I’ve also tried putting the elseif statement on it’s own in a if statement but results were still the same with it returning false

EDIT2: Whoops wait! caught on to something a issue with my debounce

So is “players” a table holding like the last times that the function ran for the player? What kind of values are you storing in it?

1 Like

Is the issue that only one if statement works every time?

1 Like

In that case have you tried printing out the value of your players table thing. It’s obvious that the value is always greater than or equal to 1.1

Well yes I did and stated it while typing up this post…

So what is the issue exactly I don’t understand.

Sorry my bad just changed the elseif statement to a else statement and it still functions as intended thanks anyways…