I have been trying hard to make a script that makes it so when you click a location, a block will turn and move to the desired location using BodyGyro's for the turning and BodyPositions for the moving.
I need some sort of more basic script that can help me out with this issue. The original script did not have proper turning, and if clicking was between 1 and 25 studs away, it only moves like 2 studs. My scripting with BodyObjects is not that good, and the wiki is not much help with this situation.
Requested section of script. Issues:
-Moving is bugged [Fixed, Part for Camera was messing with positioning]
-Turning is bugged
script.Parent.Enabled = false script.Updater.Disabled = true script.Target.Value = nil local Ship = script.OwnedShip.Value local MouseHit = nil if Ship ~= nil then MouseHit = Mouse.hit local Part = Instance.new("Part") Part.FormFactor = "Symmetric" Part.Transparency = 0 Part.Size = Vector3.new(4,4,4) Part.Anchored = true Part.CanCollide = false Part.CFrame = CFrame.new (MouseHit.X,game.Workspace.Map0.MapBase.Position.Y,MouseHit.Z) Part.Parent = game.Workspace Ship.Functional.Main.Move.position = Vector3.new (MouseHit.X,game.Workspace.Map0.MapBase.Position.Y + 5,MouseHit.Z) --Ship.Functional.Main.Gyro.cframe = CFrame.new(Vector3.new(0,0,0),Part.Position) local vec = Part.Position - Ship.Functional.Main.Position --Section from Grapple Gun local lenSquared = vec.magnitude * vec.magnitude local invSqrt = 1 / math.sqrt(lenSquared) Ship.Functional.Main.Gyro.cframe = CFrame.new(vec.x * invSqrt, vec.y * invSqrt, vec.z * invSqrt)
You should be able to set this as your Gyro's cframe to get it to point towards the mouse.
Ship.Functional.Main.Gyro.cframe = CFrame.new(Ship.Functional.Main.CFrame.p, Mouse.Hit.p)