Why doesn't this work?

Why doesn’t this work?

I am trying to make stuff near where I am aiming float.

Is it the “ply”?



function floatstuff(ply)

	plaim = ply:GetAimVector()

	floatents = ents.FindInSphere(plaim , 100 )

	for k, v in pairs(floatents) do

	
	
		v:SetGravity( -100 )

	end
	
end

concommand.Add("float", floatstuff)


GetAimVector returns a unit vector, which basically means that it’s not in world coordinates. Change GetAimVector to…

[lua]ply:GetEyeTrace( ).HitPos;[/lua]

Or something along those lines if you want to get the pos a player aiming at.

plaim is a direction. You’re wanting to make a trace:

[lua]
ply:GetEyeTrace().HitPos
[/lua]

will give you the player’s looking-at-position.

Thank you guys! :smiley:

[editline]01:38PM[/editline]

Wait now I have:
[lua]
function floatstuff(ply)

plaim = ply:GetEyeTrace( ).HitPos

floatents = ents.FindInSphere(plaim , 100 )

for k, v in pairs(floatents) do



	v:SetGravity( -100 )

end

end

concommand.Add(“float”, floatstuff)
[/lua]

Stuff isn’t floating. :S

[editline]01:41PM[/editline]

Actually it is but it’s not working on props. Is there a way to delete the sphere once the stuff’s gravity gets set? Because now whenever I walk over there and jump I fly up.

[editline]01:43PM[/editline]

Oh I think I get it, It’s because I become part of the floatents variable so now I always float. Right?

[editline]02:28PM[/editline]

Help!

[editline]02:33PM[/editline]

I’m starting a new thread.