I have a rotational error, and it hasn't fixed.

zenabled = true
local soldier = script.Parent.Parent.Parent[""]
while wait() do
local closest = nil
local dist = 12.5
for _,bloons in pairs(workspace.Bloons:GetChildren()) do
if bloons then
local mag = (script.Parent.Parent.Parent.Parent.Position-bloons.Position).magnitude
if mag < dist then
		closest = bloons
		dist = mag
		soldier:SetPrimaryPartCFrame(CFrame.new(soldier.Torso.Position,
		Vector3.new(bloons.Torso.Position.X, soldier.Torso.Position.Y, 													 
                bloons.Torso.Position.Z))*CFrame.Angles(0,-math.pi/3,0))
end
end
end
if closest and enabled then script.Parent.Parent.Parent.Parent.CFrame = CFrame.new(script.Parent.Parent.Parent.Parent.Position,closest.Position)
	    enabled = false
	    dogfrog = true
		local x = Instance.new("Part")
		x.Shape = "Ball"
		x.Material = "Neon"
		x.BrickColor = BrickColor.new(255, 176, 0)
		x.Size = Vector3.new(1,1,1)
		x.TopSurface = "Smooth"
		x.BottomSurface = "Smooth"
		x.CanCollide = false
		x.Transparency = 1
		x.Name = "Dart"
		x.Parent = workspace
		x.CFrame = script.Parent.CFrame*CFrame.new(0,0,0)
		y = Instance.new("BodyVelocity")
		y.maxForce = Vector3.new(math.huge, math.huge, math.huge)
		y.velocity = script.Parent.Parent.Parent.Parent.CFrame.lookVector*100*9
		x.Parent = game.Workspace
		y.Parent = x

x.Touched:connect(function(hit)
if hit.Name == "Red Bloon" then	
	if closest.hp.Value ~= 0 then
		print(closest.hp.Value)
		closest.hp.Value = closest.hp.Value - 1
	else
		wait(.2)
		hit:Destroy()
end
x:Remove()
end
end)
end
if dogfrog == true then
	    local shot = Instance.new("Part")
		shot.Shape = "Cylinder"
		shot.CFrame = script.Parent.CFrame*CFrame.new(0,0,0)
		shot.BrickColor = BrickColor.new(255, 176, 0)
		shot.Size = Vector3.new(0.05,0.59,0.9)
		shot.Material = "Neon"
		shot.Transparency = .3
		shot.Parent = script.Parent.Parent
		shot.Anchored = true
		dogfrog = false
		wait(.2)
		shot:Destroy()
end
wait(1)
enabled = true
end

This is supposed to rotate towards 'bloons'. Any help?

2 comments

0

Huh? What do you mean?

0

It rotates in the wrong way. It is faced a bit away from the object.