Ent Index finder works in 'Create Multiplayer' but not actual server?

How come the code below works perfectly when i ‘Create Multiplayer’ by on an actual server, it doesnt return anything?

[lua]
function EntIndexFinder(ply)
local trace = ply:GetEyeTrace()

if ValidEntity(trace.Entity) and trace.Entity:GetPos():Distance(ply:GetPos()) < 150 then
	print("The EntID is: "..trace.Entity:EntIndex())
end

end
concommand.Add(“entidfinder”, EntIndexFinder)
[/lua]

What do you mean by actual server?Also, is this client or serverside?

This is serverside. And by actual server, i mean like the ones that you buy, and are professionally hosted.

That’s because when creating a server you have both the server and client instance on your machine. When joining a dedicated server you are a client and thus can only see prints that are clientside. You could do it this way :


ply:ChatPrint("The EntID is: "..trace.Entity:EntIndex())

Perfect thanks

By the way you might have to use tostring() on that index.

Nope, worked out perfectly