Recently I started making my own Ban System for the sake of learning and having a Ban System. Everything went out perfectly fine until I tried coding the part if the player's Ban is greater than the given length e.g(1 Day, 3 Days, 1 Week). But I keep getting confused on this attempt to compare string and number error.
Line 30 is
if isBanned.BanStart - os.time() > isBanned.Length then
if any of you are wondering.
local function IsPlayerBanned(player)
local playerKey = "Player_" .. player.UserId
local isBanned
local success, errormessage = pcall(function()
isBanned = HttpService:JSONDecode(BanDataStore:GetAsync(playerKey))
end)
if success then
if isBanned.BanStart - os.time() > isBanned.Length then
BanDataStore:RemoveAsync(playerKey)
else
player:Kick(string.format("\nYou've been banned by " .. isBanned.Admin .. "\nReason: " .. isBanned.Reason .. "\n\nBanned until: " .. os.date("%B %d %X", os.time() + isBanned.Length)))
end
end
end

9 comments
is BanStart or Length a string? If so (and if they are a string with a number in them, not text) put tonumber(isBanned.BanStart) and tonumber(isBanned.Length)
previous time is less than current time, if tick()-lasttick > isbanned.length
Just converted isBanned.Length into a number and the error is now gone. But now I have a different issue, I'm currently banned from my own game and I set the Ban length to 60 seconds and it's been 2.8 hours since I banned myself and the RemoveAsync isn't working.
thats sad
Did dyou test it in studio or in game?
In studio.
Seems like I was able to figure out myself, thanks for the possible solutions guys!
yeah the problem is that you tested in studio
I don't quite understand the question But i know that comparing integers and strings is illogical. You might be able to assign a value to the string using a variable. and then compare the variable. Sorry if this doesn't help.