Jump to content

[HELP] getLocalPlayer returns nil value


Recommended Posts

Posted (edited)

Hello, I have the Following issue: I tried to set a variable to a getLocalPlayer but it just keeps returning nil value, why? My script is clientside so this is not the problem

local player = getLocalPlayer ( ) 

 

Edited by Galactix

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!

 

  • Moderators
Posted (edited)

Maybe you have another function named getLocalPlayer? So many things can cause this. With the code you showed me is nothing wrong.

 

How about you try to use the predefined variable localPlayer instead? (not a function)

(If that one returns nil, than the script is being read as a server file)

 

 

Edited by IIYAMA

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted

Now my getElementData just outputs Bad argument, expected element got nil when I write 

Quote

 local requestStatus = getElementData( localPlayer , "healrequest")

 

 

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!

 

  • Moderators
Posted
39 minutes ago, IIYAMA said:

(If that one returns nil, than the script is being read as a server file)

 

 

So not clientside.

  • Thanks 1

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted

You were right; I actually got it working, thanks so much

  • Like 1

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