Make part face fowards

  1. What do you want to achieve?
    MainMissilePartVar(Which is a variable in my script) to face the front face of its self, in other words the only way it can face is wherever the front face of MainMissilePartVar is pointing.

  2. What is the issue?
    Their is no problem I just simply do not know how to do it.

*NOTE: I AM NOT TRYING TO FIX A SCRIPT I JUST WANT TO KNOW HOW TO DO THIS

Their is more code but that is pretty much all you need to know

local MainMissilePartVar = script.Parent.MainMissilePart
2 Likes

The issue with making a Part face wherever it is facing is that if anything causes it to go ‘off course’ or rotate it will just continue to travel off course.
How are you making the missile move? CFraming? Velocity? We need more information in order to help you with your issue.

Well it moves with velocity but I used CFrame to make it look the way I want to cause its a guided missile.

I am not sure but you can probably use Rocket.CFrame.LookVector

CFrame.lookAt() will do what you want to accomplish, alternatively CFrame.new()

So your script would look like this:

local part = game.Workspace.Part
local target = game.Workspace.Target

part.CFrame = CFrame.lookAt(part.Position, target.Position)

However, such a system is probably not ideal for a missile system because the part would have no physics, you’d have to repeatedly update the position and lookAt CFrame and it would clip through parts.

The more realistic approach is to use bodymovers. Something known as a RocketPropulsion bodymover. So add it into the part, and do the following:

local part = game.Workspace.Part
local target = game.Workspace.Target

part.RocketPropulsion.Target = target
part.RocketPropulsion:Fire()
2 Likes

Hey thanks for trying to help but unfortunetly this isn’t what I need, what I need is for when the game starts, it gets the front face of a position, and then only travel in that kind of line.

use heartbeat to change the cframe of a body gyro. After the missile hits, disconnect the heartbeat.

1 Like

Then this is what you’d want. It’ll move in the front direction of the part.

local RunService = game:GetService("RunService")

local part = game.Workspace.Part
local speed = 2

RunService.Heartbeat:Connect(function()
    part.Position = part.Position + part.CFrame.LookVector * speed
end)
2 Likes

That won’t work because i’m pretty sure its not anchored. If it is it would look very choppy

1 Like

Hey probably should of explained this better my fault but I dont want to move the part as I already have a tween to move the part, I just dont want the part to wobble everywhere while its going straight up, without having to anchor parts.

use a body gyro :smiley: It is smooth and doesnt not require anchors

1 Like

Could you tell me the settings for it? cause I have tired it and it hasnt worked

That won’t work because i’m pretty sure its not anchored. If it is it would look very choppy

It works as I have tested it, and if you read my previous post I suggested the use of bodymovers to combat choppiness.

well u do bodygyro.CFrame = CFrame.new(missile.Position, target.Position) and use a heartbeat to make it change every frame.

Explorer
image
image

Sever Script

--// SERVICES \\--
local TweenService = game:GetService("TweenService")


--// VARIABLES \\--
local TrackerPartvar = script.Parent.TrackerPart


--// TWEEN INFO\\--
local AltitudeInfo = TweenInfo.new(
	
	20,
	Enum.EasingStyle.Quint,
	Enum.EasingDirection.InOut,
	0,
	false,
	0
	
)


--// TWEEN GOALS \\--
local ReachAltitude = {}
ReachAltitude.CFrame = CFrame.new(script.Parent.PrimaryPart.Position + Vector3.new(TrackerPartvar.Position.X, 500, TrackerPartvar.Position.Z))


--// CREATE TWEENS \\--
local AltitudeTween = TweenService:Create(TrackerPartvar, AltitudeInfo, ReachAltitude)


workspace.TestPart.ClickDetector.MouseClick:Connect(function()

	wait(20)

	script.Parent.ThrusterEmit.Smoke.Enabled = true

	wait(3)
	
	workspace.Silo1.SiloController.Smoke.Enabled = true
	
	script.Parent.ThrusterEmit.ParticleEmmitter.Enabled = true

	script.Parent.ThrusterEmit.SpotLight.Enabled = true
	
	TrackerPartvar.RocketPropulsion.Target = workspace.AntiAirTarget

	TrackerPartvar.Anchored = true
	
	local cf = TrackerPartvar.CFrame
	local lv = cf.lookVector
	TrackerPartvar.CFrame = cf + (lv * Vector3.new(5, 5, 5))
	
	AltitudeTween:Play()
	
	wait(5)
	
	workspace.Silo1.SiloController.Smoke.Enabled = false
	
	wait(15)
	
	TrackerPartvar.Anchored = false
	
	TrackerPartvar.RocketPropulsion:Fire()

end)

TrackerPartvar.RocketPropulsion.ReachedTarget:Connect(function()
	
	local targetExplosion = Instance.new("Explosion")
	targetExplosion.Position = script.Parent.TrackerPart.Position
	targetExplosion.ExplosionType = Enum.ExplosionType.NoCraters
	targetExplosion.BlastPressure = 1000000
	targetExplosion.BlastRadius = 400
	targetExplosion.Parent = workspace
	
	script.Parent:Destroy()
	
end)

Do you know what VectorForce is?

No I do not -------------------

Hello there.

I have read your post and the comments listed here. But I still don’t fully understand what you are trying to do.

There is a plugin for this:

If you want to use this in a script you could look in the source code and see how they find the front of the part and make it for a script!

Why use a plugin when it’s built into Studio?

Right click on any part and select “Show Orientation Indicator”:

Surface Orientation Indicator - Updates / Announcements - DevForum | Roblox