Jump to content

Player:Spawn not working


Kenpay

Recommended Posts

Posted

Hi there! I'm trying to spawn player on some location when they spawn, but I don't know why doesn't work.

function onJoin()
	outputChatBox(tostring(source))
	source:spawn(-2404.00000, -598.00000, 132.64844)
	source:fadeCamera(true)
	source:setCameraTarget(source)
end
addEventHandler("onPlayerJoin", root, onJoin)

In console i get : ERROR: [ResourceName]\[ScriptName].lua:[lineNumber]: attemp to index global 'source' ( a userdata value )
When i connect to server in chat i get : userdata: 00000097
Any ideas ?

Posted

Make sure to add the following line to your meta.xml.

<oop>true</oop>

 

  • Thanks 2

If I helped you, please click the like button on the right ;) Thanks!

Posted
12 minutes ago, myonlake said:

Make sure to add the following line to your meta.xml.


<oop>true</oop>

 

Yeah, that was the problem...I though that it is by default true.

Posted
function onJoin ()
	spawnPlayer (source, -2404.00000, -598.00000, 134.64844, 0, math.random (0,288), 0, 0) -- spawns with random skin
	fadeCamera (source, true)
	setCameraTarget (source, source)
end
addEventHandler("onPlayerJoin", getRootElement(), onJoin)

 

Posted
3 minutes ago, _Evo_ said:

function onJoin ()
	spawnPlayer (source, -2404.00000, -598.00000, 134.64844, 0, math.random (0,288), 0, 0) -- spawns with random skin
	fadeCamera (source, true)
	setCameraTarget (source, source)
end
addEventHandler("onPlayerJoin", getRootElement(), onJoin)

 

 

17 hours ago, myonlake said:

Make sure to add the following line to your meta.xml.


<oop>true</oop>

 

That was the problem

Posted
57 minutes ago, Kenpay said:
  •  
  • <oop>true</oop>

 

If I helped you, make sure you click the reaction button on the right to support me!
It will grant me more visibility and will help me to help others!

If you have any kind of request or subject you would like to discuss about with me,
don't hesitate to send me a private message about it!

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...