Jump to content

Set elementData by player name


Recommended Posts

Not really good idea cuz if can't find a player on some name, set element data will give a error.

but if you want to continue.. should look like..

  
setElementData(getPlayerFromName("name"),"data",value) 
  

This'll fix the problem:

  
local foundPlayer = getPlayerFromName("name") 
if (foundPlayer  ~= nil) then 
setElementData(foundPlayer ,"data",value) 
end 
  

Link to comment
Not really good idea cuz if can't find a player on some name, set element data will give a error.

but if you want to continue.. should look like..

  
setElementData(getPlayerFromName("name"),"data",value) 
  

This'll fix the problem:

  
local foundPlayer = getPlayerFromName("name") 
if (foundPlayer  ~= nil) then 
setElementData(foundPlayer ,"data",value) 
end 
  

Yeah i though about it, but as he said with "runcode" i didn't wanted to make a longer code lol

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