Drawtext is bugged when used with the built in GUI. Looks like a gui redraw issue.
The following shows the problem. Hit escape for menu, then click outside the buttons.
import("Scripts/Menu.lua")
window = Window:Create("example",0,0,800,600)
context = Context:Create(window)
world = World:Create()
light = DirectionalLight:Create()
light:SetRotation(45,45,0)
camera = Camera:Create()
camera:SetPosition(0,0,-3)
counter = 1400
toggle = 0
myfont = Font:Load("Fonts/arial.ttf", 16)
context:SetFont(myfont)
clip = 10
Ammo = 100
local gamemenu = BuildMenu(context)
gamemenu.newbutton:SetText("RESUME GAME")
window:HideMouse()
while window:Closed()==false do
if gamemenu:Update()==false then return end
if toggle==1 then counter = counter + 10 end
if toggle==0 then counter = counter - 10 end
if counter>=1400 then toggle = 0 end
if counter<=10 then toggle = 1 end
if gamemenu:Hidden() then
Time:Update()
world:Update()
end
world:Render()
context:SetBlendMode(Blend.Alpha)
context:SetColor(1,0,0,.5)
context:DrawRect(38,30,300,300,1,30)
context:SetColor(0,1,1,1)
context:DrawText(string.format("Ammo1: "..clip.. " | " ..Ammo), 100, 80)
context:SetColor(1,0,0,.5)
context:DrawText(string.format("%.0f",counter),38,30,300,300,Text.VCenter+Text.Center)
context:SetColor(1,1,1,1)
context:DrawText(string.format("Ammo2: "..clip.. " | " ..Ammo), 30, 100, 300, 250, Text.VCenter+Text.Center)
context:SetColor(0,1,1,1)
context:DrawText(string.format("Ammo3: "..clip.. " | " ..Ammo), 100, 300)
context:SetBlendMode(Blend.Solid)
context:Sync(true)
end