Collisions are goofing.

For some reason when I run “!test3” and then run “!test”, I cannot pick up the player again (based on ULX), I can’t kill him, I can walk into him but is pushes me or him away.

If I try to run test 3 after I ran “!test”, it will spam this error.

For whatever reason the collision aren’t being set back to normal which goofs the player object. I dunno why.

Here is the code. It basically allows a player to move another player around.


hook.Add("PlayerSay", "somethingply", function(ply, text)

	if text == "!test3" then

		local ent = ply:GetEyeTraceNoCursor().Entity
		ent.JSOCollide = ent:GetCollisionGroup()
		ent:SetCollisionGroup(COLLISION_GROUP_IN_VEHICLE)

		hook.Add("Think", "Tesysdasd", function()

			local JSradius = PoliceSystem.EscortDistance
			local copcurpos = ply:GetPos()
			local perpcurpos = ent:GetPos()
			local eyeang = ply:EyeAngles().y
			local angle = math.rad(eyeang)


			local newx = JSradius * math.cos(angle) + copcurpos.x
			local newy = JSradius * math.sin(angle) + copcurpos.y

			ent:SetPos(Vector(newx, newy, copcurpos.z))
			ent:SetEyeAngles(Angle(0, tonumber(eyeang), 0))

		end)

		--hook.Remove("Think", "Tesysdasd")

		--ply:ChatPrint("Old Pos: " .. tostring(curpos.x) .. "  :  " .. tostring(curpos.y))
		--ply:ChatPrint("New Pos: " .. tostring(newx) .. "  :  " .. tostring(newy))
		--ply:ChatPrint("Angle: " .. tostring(angle))

	end

	if text == "!test" then

		local ent = ply:GetEyeTraceNoCursor().Entity
		hook.Remove("Think", "Tesysdasd")
		if not(ent.JSOCollide) then
			ent:SetCollisionGroup(COLLISION_GROUP_NONE)
		else
			ent:SetCollisionGroup(ent.JSOCollide)
		end

	end
end)


-snip-
The entity is not a player

So apparently the “!test3” code make the player a Entity[0][worldspawn].

I assume because of the collision. Should I just change the type of collision or should I make a hook inside of the think hook that is basically “!test”