Jump to content

Cant print anything via console


Recommended Posts

Tried the simplest thing that came to my mind print(ThePlayer.components.health.currenthealth), and im getting [string "print(ThePlayer.components.health.currenthe..."]:1: attempt to index field 'health' (a nil value) attempt to call a nil value error. what is going on?

Link to comment
Share on other sites

If you're running this on a caverns-enabled self-hosted server, then you'll have to run it on the server and not your local client to get it to work.  It will print to the server's log file, however, and not to your console.

Reason being is that in this setup the client does not know about the health component directly but has a replica that it goes through to access its values via a networked variable.

 

If you do this on a non-caves server, then the client and server are one and this will work with no strings attached.

Link to comment
Share on other sites

1 hour ago, Parusoid said:

Ok so its the caves that causes it. Can I call replica somehow?

If you are still the host (of the caves world), you can hit "CTRL" on your keyboard, left to the console it should switch between "Local" to "Remote" and the other way round, while it is remote it sends your commands as server.
Keep in mind that you wont see the prints in the client log, when send with the server, you will see them within the server log you find within your cluster logfiles.

This "switch" is of course only possible if you are still host, for real clients you cant do this, therefore you also cant use this within mods.
Within the components folder you can see some "replicas" and eg see that there is indeed a health replica, so yes you can call this with inst.replica.health:GetCurrent().

Link to comment
Share on other sites

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
 Share

×
  • Create New...