DropToFloor a player

Hi, I wonder how to drop to floor a player after he has been teleported so he doesn’t go through walls or in the void.

Thanks for answers ^^

What do you mean?

I’m makind a SWEP so when the player press Right Click he is teleported to where he was looking at.
But sometimes the player go through walls and ceilings.

Check if the vector is in the world using util.IsInWorld() and if it’s false return an error
I would provide a snippet but editing on a phone isn’t ideal (autocorrect)

It is probably because of the hitbox and origin of the player which is at the middle on the feet. So if you set a player’s position to the the roof, it’s their feet that will be set there with the rest of the body going through it. If this is what happens to you, you could probably use the trace’s HitNormal and offset the position by the players collision box.

Found a solution:

	local droptofloor = ents.Create( "prop_physics" )
if ( !IsValid( droptofloor ) ) then return end // Check whether we successfully made an entity, if not - bail
droptofloor:SetModel( "models/props_junk/watermelon01.mdl" )
droptofloor:SetPos( trace.HitPos )