I have tried everything, but I cannot seem to change the lookVector of a union part to the lookVector of the lower torso, upper torso, etc.
Here is the code so far:
local player = game.Players.LocalPlayer local s = game.ReplicatedStorage.Spaceship local ts = game:GetService("TweenService") local p = s:Clone() p.Parent = game.Workspace p.Name = player.Character.Name .. "Spaceship" local info = TweenInfo.new( 1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out ) local debounce = false while true do wait(0.1) local bodyPart = player.Character:FindFirstChild("LowerTorso").CFrame local goals = {CFrame = CFrame.new(bodyPart.X, 5, bodyPart.Z)} local tween = ts:Create(p, info, goals) tween:Play() end
Thanks for the Help!
How to change the facing of a part to the facing(lookvector) of character?
If you want to make partA
look at partB
while remaining in position of partA
then you can use CFrame.new
with two Vector3 paramteres.
https://developer.roblox.com/en-us/api-reference/datatype/CFrame
CFrame.new(vector3Position, vector3Direction)
.
This creates a CFrame
whose Position
is vector3Position
and rotation is pointing towards the vector vector3Direction
Then we would set partA.CFrame
to our new CFrame.
partA.CFrame = CFrame.new(partA.Position, partB.Position)
So if you were wanting to make a part face the LowerTorso
of a character;
somePart.CFrame = CFrame.new(somePart.Position, lowerTorso.Position)
And if you wanted to make LowerTorso
face somePart
just reverse the order.
* Make sure to set the y-coordinate
of somePart
's position to the LowerTorso
's y-coordinate
or you might see some weird angle issues.
CFrame.new(lowerTorso.Position, Vector3.new(somePart.Position.X, lowerTorso.Position.Y, somePart.Position.Z)