Help 3dtext is not working

Why is this not working? anyone? help?

Client.lua

function Draw3DText(x, y, z, text)
local onScreen, _x, _y = World3dToScreen2d(x, y, z)
local p = GetGameplayCamCoords()
local distance = GetDistanceBetweenCoords(p.x, p.y, p.z, x, y, z, 1)
local scale = (1 / distance) * 2
local fov = (1 / GetGameplayCamFov()) * 100
local scale = scale * fov
if onScreen then
SetTextScale(0.0scale, 0.35scale)
SetTextFont(0)
SetTextProportional(1)
SetTextColour(255, 0, 0, 255)
SetTextDropshadow(0, 0, 0, 0, 255)
SetTextEdge(2, 0, 0, 0, 150)
SetTextDropShadow()
SetTextOutline()
SetTextEntry("STRING")
SetTextCentre(1)
AddTextComponentString(text)
DrawText(_x,_y)
end
end

Draw3DText(-1035.8546142578,-2734.6867675781,13.75664806366, tostring("Server Founder: El Diablo"))

__resource.lua

resource_manifest_version '05cfa83c-a124-4cfa-a768-c24a5811d8f9'

client_script 'client.lua'

Please tell me if some thing is wrong

You’re only drawing it for 1 frame. Needs to be in a loop. Also, use SetDrawOrigin instead of drawing 3D text manually.

okay Thank you Vespura

So is this right?

function DrawName3D(x,y,z, text) -- some useful function, use it if you want!
    SetDrawOrigin(x, y, z, 0);
    SetTextFont(0)
    SetTextProportional(0)
    SetTextScale(0.0, 0.23)
    SetTextColour(255, 0, 0, 255)
    SetTextDropshadow(0, 0, 0, 0, 255)
    SetTextEdge(2, 0, 0, 0, 150)
    SetTextDropShadow()
    SetTextOutline()
    SetTextEntry("STRING")
    SetTextCentre(1)
    AddTextComponentString(text)
    DrawText(0.0, 0.0)
    ClearDrawOrigin()
end

while true do

DrawName3D(-1035.8546142578,-2734.6867675781,13.75664806366, tostring("Server Founder: El Diablo"))
DrawName3D(-1035.8546142578,-2734.6867675781,17.75664806366,"Server Founder: El Diablo")

end

No that’d crash your game because you have it in a while loop without wait, and without it being in a thread.

1 Like