My objective is to make a tracking part that swivels, following the movements of a projectile. This is my current failure of a script:
Stop = false game.Workspace.ProjectilePhysicsTest.Projectile.Touched:connect(function (touched) if touched.Name == "Baseplate" then Stop = true end end) repeat wait() script.Parent.Rotation = (script.Parent.Position - game.Workspace.ProjectilePhysicsTest.Projectile.Position).magnitude * game.Workspace.ProjectilePhysicsTest.Projectile.Position until Stop == true
Any help would be appreciated.
There is a CFrame constructor that does precisely what you want. The syntax for it is this;
CFrame.new( Vector3 origin, Vector3 look)
origin being the position of the part, and look being where the part is looking at.
Stop = false game.Workspace.ProjectilePhysicsTest.Projectile.Touched:connect(function(touched) if touched.Name == "Baseplate" then Stop = true end end) repeat wait() script.Parent.CFrame = CFrame.new( script.Parent.CFrame.p, workspace.ProjectilePhysicsTest.Projectile.CFrame.p ) until Stop
Note: This CFrame constructor always points the FrontSurface or the part to the look argument