Jump to content

Player:Spawn not working


Kenpay

Recommended Posts

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 ?

Link to comment
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)

 

Link to comment
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

Link to comment

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...