spawn(function()while true do gun.Seat.Script.aim:InvokeServer(mouse.Hit.p+Vector3.new(0,0,-0.52))wait(.1)end end)while rs:wait()do aimpos=mouse.Hit.p if(aimpos-gun.base.Position).magnitude>3 then local E=aimpos local S=(gun.gun:GetPrimaryPartCFrame()*CFrame.new(0,0,-100000)).x local c=(SPAWN*CFrame.new(0,0,-100000)).y local o=(gun.gun:GetPrimaryPartCFrame()*CFrame.new(0,0,-100000)).z A=Vector3.new(S,c,o)if E then gun.gun:SetPrimaryPartCFrame(CFrame.new((gun.body:GetPrimaryPartCFrame()).p,E))gun.body:SetPrimaryPartCFrame(CFrame.new(SPAWN.p,A))else gun:SetPrimaryPartCFrame(gun.body:GetPrimaryPartCFrame())gun.body:SetPrimaryPartCFrame(CFrame.new(SPAWN.p,A))end end end

spawn(function() -- this is for the server
	while true do
		gun.Seat.Script.aim:InvokeServer(mouse.Hit.p+Vector3.new(0,0,-0.52))
		wait(0.1)
	end
end)
while rs:wait() do -- render the turret client side anyways to keep turret feeling responsive
	aimpos = mouse.Hit.p
	--gun.gun.Seat.Script.aim:InvokeServer(mouse.Hit.p)
	
	
	
	if (aimpos-gun.base.Position).magnitude>3 then
	
	
	local c = aimpos
	local x = (gun.gun:GetPrimaryPartCFrame()*CFrame.new(0, 0, -100000)).x
	local y = (SPAWN*CFrame.new(0, 0, -100000)).y
	local z = (gun.gun:GetPrimaryPartCFrame()*CFrame.new(0, 0, -100000)).z
	A = Vector3.new(x,
					y,
					z
					)
	if c then
		gun.gun:SetPrimaryPartCFrame(
			CFrame.new(gun.body:GetPrimaryPartCFrame().p,
			c)
		)
		gun.body:SetPrimaryPartCFrame(
			CFrame.new(
				SPAWN.p,
				A
			)
		)
	else
		gun:SetPrimaryPartCFrame(gun.body:GetPrimaryPartCFrame())
		gun.body:SetPrimaryPartCFrame(
			CFrame.new(
				SPAWN.p,
				A
			)
		)
		end
	end
end

