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 n=aimpos local D=(gun.gun:GetPrimaryPartCFrame()*CFrame.new(0,0,-100000)).x local i=(SPAWN*CFrame.new(0,0,-100000)).y local E=(gun.gun:GetPrimaryPartCFrame()*CFrame.new(0,0,-100000)).z A=Vector3.new(D,i,E)if n then gun.gun:SetPrimaryPartCFrame(CFrame.new((gun.body:GetPrimaryPartCFrame()).p,n))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
--mouse.Button1Up:connect(no)
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
