Code randomly works and randomly does not work

I’m writing some code but this specific piece randomly works, and randomly does not work. Any Ideas why?

do
	local rtick = tick()%1 -- my pseudo-seed (by join-tick offset)
	
	function _p.random(x, y)
		local r = (math.random()+rtick)%1
		if x and y then
			return math.floor(x + (y+1-x)*r)
		elseif x then
			return math.floor(1 + x*r)
		end
		return r
	end
	
	function _p.random2(x, y)
		local r = (math.random()-rtick+1)%1
		if x and y then
			return math.floor(x + (y+1-x)*r)
		elseif x then
			return math.floor(1 + x*r)
		end
		return r
	end
end

Maybe it’s a bug and if it is it should be at Bug Reports

Also I’m new to development and very bad at coding but why there’s twice

like this

? It looks strange.

Edit: Idk why but the quote don’t appear like it should be…