trying too learn some Gmod lua "SafeRemoveEntity"

trying to remove a entity.

local eyetrace = LocalPlayer():GetEyeTrace().Entity
SafeRemoveEntity( eyetrace )

But get this error
Trying to remove server entity on client!

what am i doing wrong?
Can´t i use SafeRemoveEntity on both client and server?

If the entity was created client side then you **can ** remove it using any removal method that you want. The reason why you are getting that error is because you’re trying to remove an entity from the server realm. This goes the same for server trying to remove clientside entities (well the server wouldn’t actually know they exist since they are on the client)

In order to remove an entity from the server requested from the client realm, you would basically have to tell the server to remove that entity through any kind of networking operation such as the net library.

SafeRemoveEntity is the same as entity:Remove() except it has some extra checks that you don’t have to write such as making sure the entity you’re trying to remove is valid and that the entity you’re trying to remove is not a player

Should i not use net.WriteEntity() when sending my eyetrace to server ? :smile:

Just run GetEyeTrace on the server.

Got it to work Thaks All :slight_smile: