
I am trying to make it so the text appears when the different of coordinates from the player and the ped is less than 3 and when greater than 3 it goes away.
here are my functions aswell

I am trying to make it so the text appears when the different of coordinates from the player and the ped is less than 3 and when greater than 3 it goes away.
It doesn’t look like you’re updating playerCoords in that loop.
If you don’t update that, then the script will never know you moved.
Whatever you’re doing to obtain playerCoords, do it inside the loop.
A bunch of problems and possible improvements with your code.
As @Demonen pointed out, you should move the player = PlayerPedId() inside the Citizen.CreateThread()and playerCoords = GetEntityCoords(player) inside the while true do, so that the player’s coordinates are updated every tick. Also, it seems that the PlayerPedId() native doesn’t take any parameters, did you maybe mean to use GetPlayerPed(-1)? Although I think both have the same effect (I personally always used GetPlayerPed(-1) to get the local player).
In the GetDistance() function, you’re passing what looks like 2 parameters of type vector3 then creating 2 new vector3s by unpacking the x, y, z fields… You can just do return #(originCoords - objectCoords) instead of that nonsense.
You made your own function called RequestModel() which has the same name as a FiveM native and this may cause a conflict, may no be entirely correct (I’m like 80% sure), but a thing to keep in mind.
You should try to use local variables more, if you don’t truly need global ones, such as your player and playerCoords variables.
After you get it working as intended, you could also improve the performance of the while true do loop using a variable wait timer. For example, making the loop wait 1 or 2 seconds if the player is not in range and 0 or 1 miliseconds if the player is in range and you need to draw stuff every frame.
Ahh i see thanks for the help i get what ive done wrong now and ive taken your feedback on thanks for the response man i appreciate it
thanks for the help aswelll @Demonen
No problem.