CreateRandomPed, does it works or not?

Hi guys,

Does anyone can explain me why “CreateRandomPed” functions doesn’t work at all while “CreatePed” works?? Or may be there is some special use for it?

https://runtime.fivem.net/doc/reference.html#_0xB4AC7D0CF06BFE8F

Creates a Ped at the specified location, returns the Ped Handle.
Ped will not act until SET_PED_AS_NO_LONGER_NEEDED is called.

Thanks for your reply. I knew that but it doesn’t work at all. I have tried:

       playerX, playerY, playerZ = table.unpack(GetEntityCoords(GetPlayerPed(-1), true))
       newCoordX = playerX + math.random(-100, 100)
       newCoordY = playerY + math.random(-100, 100)

       ped = CreateRandomPed(newCoordX, newCoordY, playerZ)
       SetPedAsNoLongerNeeded(ped)

Is there an error in the console, or no. Also, maybe try this, IDK if math.random works for negative integers:

       playerX, playerY, playerZ = table.unpack(GetEntityCoords(GetPlayerPed(-1), true))
       newCoordX = playerX + (math.random(200) - 100)
       newCoordY = playerY + (math.random(200) - 100)

       local ped = CreateRandomPed(newCoordX, newCoordY, playerZ)
       SetPedAsNoLongerNeeded(ped)

Thank you @BlockBa5her. No it still doesn’t work and there is no error in the console unfortunately.
“CreatePed” function works with these random coords so I don’t think it is about the math.random.

Just to clarify,is your function on a server side or client side script

@BlockBa5her On client side.