Physgun beam always stays at same position

When I move my anim, the physgun beam is always placed in spawn point. I woke up physics, activated entity, but nothing works. The only file is “shared.lua”. How do I fix that?

Show us your code. (Use [noparse][lua][/lua][/noparse] tags!)

[lua]
function ENT:SpawnFunction( ply, tr )
if !tr.Hit then return end
local NewTree = ents.Create(ClassName)
NewTree:SetPos(tr.HitPos)
NewTree:SetAngles(Angle(0,0,0))
NewTree.Owner=ply
NewTree.Dry=0
NewTree.Fruits=0
NewTree.NewStage=0
NewTree.Stage=0
NewTree:Spawn()
NewTree:Activate()
NewTree:PhysWake()
return NewTree
end

function ENT:Initialize()
if SERVER then
self:SetUseType(SIMPLE_USE)
end
self:SetModel(“models/props_foliage/tree_deciduous_03b.mdl”)
self:DrawShadow(true)
self:PhysicsInit(SOLID_VPHYSICS)
self:SetMoveType(MOVETYPE_VPHYSICS)
self:SetSolid(SOLID_VPHYSICS)
self:SetColor(255,255,255,255)
end
[/lua]

if SERVER then
self:SetUseType(SIMPLE_USE)
end

Initialize is a serverside function, you shouldn’t be calling those in shared.lua.

He is only running the code on server tho.
if Server then end means that the code in there only runs on server

The functions aren’t in an if statement from what I see…

>>you shouldn’t be calling those in shared.lua.

I’m making Toybox SENT. All Toybox SENTs are in one file.

And, “use” is not related to physgun. I initialize physics OUT of if SERVER end, and I wake physics up in SpawnFunction.

I get the feeling you’re meant to call entity.Spawn in the Initialise function. Worth trying, but don’t take it for granted (I haven’t made any entities in a large number of months)

Initialize is called by Spawn

Putting it in the shared folder is fine, he’s not calling the functions at all. (Sure they’re a waste of space but they don’t cause any trouble)

@SiPlus666 please show us your whole file, instead of just those 2 functions.

>>I get the feeling you’re meant to call entity.Spawn in the Initialise function.

I call entity:Spawn in SpawnFunction, not in Initialize. Read the code.

>>Sure they’re a waste of space but they don’t cause any trouble

In Toybox there is only ONE lua script can be posted.

Yes, now read the rest of my post so we can help you further.

Problem fixed - spawn and init should be called only on server.