[Help] SwitchOutPlayer attempts to call nil value

Heyo.

So lately I’ve been getting myself into trying to code a gamemode for my community, where I wanted to use SwitchOutPlayer as part of a transition between parts of the world when teleporting, but I’ve run into some problem, that I hope someone would be able to help me solve.

First off, the little snippet of code, that i almost always use to test small bits of clientside code:

Citizen.CreateThread(function()
	while true do
		Citizen.Wait(0)
		if IsControlJustPressed(0,38) then
		 SwitchOutPlayer(PlayerPedId(),0,1) --Brings up the player.
		 SetEntityCoords(PlayerPedId(),-97.489700317383,241.09867858887,99.021774291992, 1, 0, 0, 1) --Predefined for testing
		 N_0xd8295af639fd9cb8(PlayerPedId()) --Brings down the player.
		end
	end
end)

This code works fine, if i chose to comment out SwitchOutPlayer and N_0xd8295af639fd9cb8.

And the error it gives me back in the F8 console:

Error resuming coroutine: client.lua:5: attempt to call a nil value (global 'SwitchOutPlayer')
stack traceback:
client.lua:5: in function <client.lua:1>

So far, this is what I have tried myself:

  1. Using GetPlayerPed(-1) instead of PlayerPedId()
  2. Tried changing the numbers around 1,0 and 1,1

But with no luck at all. So I’m not entirely sure, what is attempting to call a nil value in there.

If anyone is able to help, i would appreciate it alot. If not enough information is given, i will happily provide more. Thanks.

1 Like

are you using a resource manifest version?

I am indeed, this is my __resource.lua file.

resource_manifest '44febabe-d386-4d18-afbe-5e627f4af937'

client_script 'client.lua'

Should it be updated to something else?

#bump - Any solutions yet?

this is an old topic, you still having this same exact issue with the same exact code? if not, please create a new topic for this. (if you want you can link this topic in there as reference to a similar case)

2 Likes

Just found an other topic to the same event. Just commented to it, too.

Thanks for your answer anyways, Vespura.

2 Likes