Entity:SetModel bug


function SWEP:ShootProp(model_name)

	self:EmitSound( ShootSound )

 
	if ( CLIENT ) then return end

	local ent = ents.Create( "prop_physics" )

	if (  !IsValid( ent ) ) then return end


	ent:SetModel( model_name )
 

	ent:SetPos( self.Owner:EyePos() + ( self.Owner:GetAimVector() * 16 ) )
	ent:SetAngles( self.Owner:EyeAngles() )
	ent:Spawn()
 


	local phys = ent:GetPhysicsObject()
	if (  !IsValid( phys ) ) then ent:Remove() return end
 
 

	local velocity = self.Owner:GetAimVector()
	velocity = velocity * 100000
	phys:ApplyForceCenter( velocity )

	cleanup.Add( self.Owner, "props", ent )
 
	undo.Create( "Shot prop" )
		undo.AddEntity( ent )
		undo.SetPlayer( self.Owner )
	undo.Finish()
end

Then I change model_name the prop spawns with the default model_name I have set “models/props_junk/watermelon01.mdl”

It’s not a bug with Entity:SetModel, but a bug with your coding.

Well you could atleast try to explain me that’s wrong or how to fix it

Post more code. Especially the part which actually calls ShootProp, and how you are “changing” model_name.

this one calls


function SWEP:PrimaryAttack()
	self.Weapon:SetNextPrimaryFire( CurTime() + 0.5 )	


	self:ThrowChair( prop )
	if ( SERVER ) then return end
	chat.AddText("You shot ",prop) --I check if I really changed the directory
end

this one changes


local PropEntry = vgui.Create( "DTextEntry", Menu2 )
PropEntry:SetPos( 10, 47 )
PropEntry:SetSize( 300, 20 )
PropEntry:SetText( prop )
PropEntry.OnEnter = function( self )
	prop=self:GetValue()
end

You must send the model name from that panel to your SWEP via net message.

What you tried to do is to set a variable on client and then you expect it to magically change on the server as well.

So how do I set a variable on the server please explain it to me I’m a total noob

http://forum.facepunch.com/showthread.php?t=1367953

I fixed it myself but now I have another problem how do I execute something serverside in a menu

The same exact way you send a variable.