Teleportation Script (scripting beginner)

Hello guys this is my first ever own script! I dont know if it works because im not at home right now. Maybe some of you could see if it works.

My idea was instead of going into noclip as an admin searching a location to just type a simple command like /pd (pd standing for = Police Department and to get teleported infront of the PD because people are lazy…

if the script does not work pls tell me why so i can improve :wink:

RegisterCommand("pd", function(source, args,)

    local ped = PlayerPedId()

    local currentPos = GetEntityCoords(ped)

    SetEntityCoords(ped, 436.491, -982.172, 30.699, false, false, false, false)

    

    Citizen.CreateThread(function()

        AddTextEntry("^5[TELEPORTIERT]^5", currentPos)

    end)

end)
1 Like

Creating a thread inside a command is usually a bad idea - plus, the way you add text isn’t nearly the best option here (and it probably wont work if I recall the way that native is done correctly).
Assuming you dont have anything like ESX that you’re using on the server, using, say, this native to fire a notification will work much better.

2 Likes

make it serversided and check the permission before executing it

2 Likes

thanks

2 Likes