Hadif Posted August 3, 2015 Share Posted August 3, 2015 Hey guys, I have made a script that spawn a player when player logs in. But, it is not working and the debug console not show any errors. Any help will be appreciate, thank you! Script: addEventHandler ( "onPlayerLogin", getRootElement ( ), function ( ) setPlayerSpawn ( ) end ) function setPlayerSpawn ( ) setPlayerSpawnPosition ( source ) end function setPlayerSpawnPosition ( player ) local positions = { { -894.90002, 1963, 0.6, 14 }, { -893.40002, 1963.4, 60.6, 14 }, { -891.79999, 1963.8, 60.6, 14 } } local randomize = math.random ( 1, #positions ) spawnPlayer ( player, positions [ randomize ] [ 1 ], positions [ randomize ] [ 2 ], positions [ randomize ] [ 3 ], positions [ randomize ] [ 4 ] ) end Link to comment
JR10 Posted August 3, 2015 Share Posted August 3, 2015 source is not defined in setPlayerSpawn, you need to add it as an argument. addEventHandler ( "onPlayerLogin", getRootElement ( ), function ( ) setPlayerSpawn (source ) end ) function setPlayerSpawn ( player ) setPlayerSpawnPosition ( player ) end function setPlayerSpawnPosition ( player ) local positions = { { -894.90002, 1963, 0.6, 14 }, { -893.40002, 1963.4, 60.6, 14 }, { -891.79999, 1963.8, 60.6, 14 } } local randomize = math.random ( 1, #positions ) spawnPlayer ( player, positions [ randomize ] [ 1 ], positions [ randomize ] [ 2 ], positions [ randomize ] [ 3 ], positions [ randomize ] [ 4 ] ) end Link to comment
Hadif Posted August 3, 2015 Author Share Posted August 3, 2015 source is not defined in setPlayerSpawn, you need to add it as an argument. addEventHandler ( "onPlayerLogin", getRootElement ( ), function ( ) setPlayerSpawn (source ) end ) function setPlayerSpawn ( player ) setPlayerSpawnPosition ( player ) end function setPlayerSpawnPosition ( player ) local positions = { { -894.90002, 1963, 0.6, 14 }, { -893.40002, 1963.4, 60.6, 14 }, { -891.79999, 1963.8, 60.6, 14 } } local randomize = math.random ( 1, #positions ) spawnPlayer ( player, positions [ randomize ] [ 1 ], positions [ randomize ] [ 2 ], positions [ randomize ] [ 3 ], positions [ randomize ] [ 4 ] ) end Are you sure? Ill try this later. Anyway, thanks for your help. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now