Attempting to create a very simple teleportation script for fun


I’m trying to use the code from this because of the command activating something.
I figured because this activated the message in the chat, I could modify it to also teleport the player, but I can’t seem to get it working.

Here are some images of scrapped code that I swapped out for the original stuff from the linked post:
server.lua :
client.lua :

Also sorry if this isn’t the right place to post this, still trying to figure out the forums!
(Also i know in the client.lua picture the teleport code is a comment, just wanted to try get the text to work)


You do not need a server.lua for this. Only client.lua:

RegisterCommand('hospital', function()


What Scott_UK told you is correct, also you are calling the native SetPedCoordsKeepVehicle(...) wrong.

Natives don’t have to be called with TriggerEvent(...).

You just call them how they are.


Clientsided Script

RegisterCommand('hospital', function(Source, Arguments, RawCommand)
	if #Arguments == 3 then
		if IsPedInAnyVehicle(PlayerPedId(), 0) and (GetPedInVehicleSeat(GetVehiclePedIsIn(PlayerPedId(), 0), -1) == PlayerPedId()) then
			SetPedCoordsKeepVehicle(PlayerPedId(), Arguments[1], Arguments[2], Arguments[3])
			SetEntityCoords(PlayerPedId(), Arguments[1], Arguments[2], Arguments[3])
		TriggerEvent('chatMessage', '', {0, 255, 0}, 'Teleported successfully!')
		TriggerEvent('chatMessage', '', {255, 0, 0}, 'Argument count mismatch! Expected 3, got ' .. #Arguments .. '!')


Forgive me for not understanding this, but I don’t understand the arguments within the code, how do those work? I tried entering the xyz’s into them accordingly but that didn’t work, and how would I define the action(‘Hospital’) within Scott’s code? I get the main idea, its just how to fill in the information for the command and how to execute it is what’s tying me up right now.


I dont know lua but c# but from my understanding you have to call the hospital command thru ingame chat like: /hospital

and pass the coordinates as arguments.


I got the /hospital part down, that part is working.


Then what is it you don’t understand




I’ll type in the game chat /showid and then it proceeds to spew out a long error message in the chat.
give me a moment and ill grab a screenshot