constraint.Keepupright not working?

I remember trying to use this constraint before many time and only succeeded once but I cant remember how I did it…
Anyways this gives me no errors and doesn’t work either.

Here is the Initialize function from init.lua

function ENT:Initialize()

	self:SetModel( "models/props_lab/crematorcase.mdl" )
	self:PhysicsInit( SOLID_VPHYSICS )
	self:SetMoveType( MOVETYPE_VPHYSICS )
	self:SetSolid( SOLID_VPHYSICS )
	self:SetAngles( Angle(0,0,180) )  
	constraint.Keepupright( self, Angle(0,0,180), 0, 500 )
    phys = self:GetPhysicsObject()
	if (phys:IsValid()) then

constraint.Keepupright( ent, Phys:GetAngles(), 0, 999999 )

Have you tried using the default wiki? The lower the 3rd argument the lesser kept up it is.
And I am talking about going to 500,000 or some shit, 500 will do nothing.

BUMP (Still dont know how to do this ;_:wink:

I tried what you said and it doesnt work. .-.

	Keepupright( ... )
	Creates a KeepUpright constraint
function Keepupright( Ent, Ang, Bone, angularlimit )

	if ( !CanConstrain( Ent, Bone ) ) then return false end
	if ( Ent:GetClass() != "prop_physics" && Ent:GetClass() != "prop_ragdoll" ) then return false end
	if ( !angularlimit or angularlimit < 0 ) then return end

	local Phys = Ent:GetPhysicsObjectNum(Bone)

	-- Remove any KU's already on entity
	RemoveConstraints( Ent, "Keepupright" )

	onStartConstraint( Ent )

		local Constraint = ents.Create( "phys_keepupright" )
		Constraint:SetAngles( Ang )
		Constraint:SetKeyValue( "angularlimit", angularlimit )
		Constraint:SetPhysConstraintObjects( Phys, Phys )

	onFinishConstraint( Ent )
	AddConstraintTable( Ent, Constraint )

	local ctable = {
		Type = "Keepupright",
		Ent1 = Ent,
		Ang = Ang,
		Bone = Bone,
		angularlimit = angularlimit
	Constraint:SetTable( ctable )

	-- This is a hack to keep the KeepUpright context menu in sync..
	Ent:SetNWBool( "IsUpright", true )

	return Constraint

duplicator.RegisterConstraint( "Keepupright", Keepupright, "Ent1", "Ang", "Bone", "angularlimit" )

Here’s the line that’s causing your code to fail:

if ( Ent:GetClass() != "prop_physics" && Ent:GetClass() != "prop_ragdoll" ) then return false end

You’re using a custom entity.

constraint.Keepupright It says it works only with props and ragdolls, dang, why people dont read the wiki first?