Why are you doing local jailed = FreezeEntityPosition. Then youâre doing jailed = true. I know Lua doesnât have types like other languages but, this is just taking the mick 
Anyways, the native youâre trying to use doesnât have a return type so, you donât need to do jailed = freezeEntityPosition. See here.
As other have said, you should not be trying to call the client function from the server code unless itâs through an event. So, letâs see if we can make this a bit cleaner. Letâs assume youâre using a command to jail someone, you would need to first get the closest player to jail from the cop. So, you could do something like this on the server (when the command is executed).
Note: this is pseudocode and wonât work out-of-the-box.
On command do {
TriggerClientEvent("jail:jailClosestPlayer", source)
}
Then, on the client you would have to register and handle the event. In the handler you could either write the logic inside it or, you could call your jail function.
RegisterNetEvent("jail:jailClosestPlayer")
AddEventHandler("jail:jailClosestPlayer", function()
JailClosest()
end)
-- or
RegisterNetEvent("jail:jailClosestPlayer")
AddEventHandler("jail:jailClosestPlayer", function()
t, distance = GetClosestPlayer()
if(distance ~= -1 and distance < 3) then
TriggerServerEvent("jail:jailPlayer", GetPlayerServerId(t)) -- send server Id to freeze
end
end)
Then you would have to handle that event on the server, probably triggering yet another client event (i donât know if its possible but, you might be able to do TriggerClientEvent("event", GetPlayerServerId(t)) but, Iâm not too sure). Looking something like
On event "jail:jailPlayer" (int target) {
TriggerClientEvent("jail:jailPlayerClient", target)
}
The your final event would handle freezing the player and doing other stuff. E.g.
local isInJail = false; -- is player in jail?
On event "jail:jailPlayerClient"{
isInJail = not isInJail
FreezeEntityPosition(GetPlayerPed(-1), isInJail)
}
Phew. That was a lot of text
. Iâm on phone so, code wonât be good and there will almost certainly be typos.