Problems with tweening welded part orientations

I’m trying to make it so that these eyes look at nearby players individually.
image
The problem is that the entire model is unanchored, and the eyes are welded to the base of the enemy.
This makes it so whenever I try to change the CFrame of one of the eyes, the entire model is offseted around the eye.
image
(Right Eye looking at 100,100,0 | Same angle)

I’ve tried to also tried to change the orientation property of the eye but for some reason when I do that the position is also affected
image
(C1 > Orientation | “0,0,0” → “0,-1,0”)

This is the part of my code that is supposed to rotate the eye.
It doesn’t do anything noticeable when I run it, except making the entire model glitch out and fling itself.

game:GetService("TweenService"):Create(script.Parent, TweenInfo.new(.1, Enum.EasingStyle.Circular, Enum.EasingDirection.Out, 0, false, 0), {CFrame = CFrame.new(script.Parent.Position, target.Position)}):Play()

Any help is appreciated!
Thank you in advance :blush:

would be nice if anyone responded been waiting for over 20 mins :confused:

Why don’t you use CFrame.LookAt()?

Thanks, I tested it with it and this time it worked. I’m going to test it in game and let you know if it works as intended.

You cannot change the CFrame of the eyes directly due to the weld. Instead, you have to manipulate the C0 and C1 of the weld itself. Refer to this for some explanation, and let me know if you’d need some help with it. I am not the CFrame master, but I can give it a try.

Nevermind, for some reason it worked flawlessly the first time I tested it, but now after I’ve reran the test it is giving the same problem as before.

Before running
image

After running
image

It is completely skipping the tween aswell.

local script = game.Workspace[""].Head.Eye.LookAt local target = Instance.new("Part") script.Parent.CFrame = CFrame.new(script.Parent.Position, Vector3.new(0,0,0)) game:GetService("TweenService"):Create(script.Parent, TweenInfo.new(1, Enum.EasingStyle.Circular, Enum.EasingDirection.Out, 0, false, 0), {CFrame = CFrame.lookAt(script.Parent.Position, target.Position)}):Play()

(Running this in command bar)

It would help if you listened to what “Volieb” is saying.
Using the C0 or C1 of a weld you can manipulate the orientation of the weld’s CFrame.
It would usually look something like this

Weld.C0 = CFrame.new(-PositionVector-) * CFrame.Angles(-Type the new orientation here-)

Oh, I didn’t see Volieb’s post. Sorry about that. I will experiment with what you and Volieb said to try and get it to work. If I make any progress I’ll let you know.

Unfortunately this didn’t work either. What I did was I used CFrame.lookAt to orient the eye, then I copy and pasted the orientation (from the explorer) into the angles and it still changed the position of the eye.

script.Parent.Weld.C0 = CFrame.new(script.Parent.Weld.C0.Position) * CFrame.Angles(math.rad(-1.014), math.rad(40.101), math.rad(0.135))


Am I doing something wrong?

In

script.Parent.Weld.C0 = CFrame.new(script.Parent.Weld.C0.Position) * CFrame.Angles(math.rad(-1.014), math.rad(40.101), math.rad(0.135))

Change CFrame.new(script.Parent.Weld.C0.Position) * CFrame.Angles(math.rad(-1.014), math.rad(40.101), math.rad(0.135)) to CFrame.new(0,0,0) * CFrame.Angles(math.rad(-1.014), math.rad(40.101), math.rad(0.135))

image
The distance between the eye and the present is much smaller, but it still got moved.

Which part is getting move? Is it the box or the eyeball

Both of them, the eye and the box are getting moved.

Can I see where the weld and it’s properties are in the object view tab

Hhm, weld’s properties seem to change since a lasted used them so I can’t help much now. I would recommend looking through Devforum since I know there is a lot on weld’s C0 properties

Ok, I’ll keep that in mind
(characters 30 minimum)

Set the Part0 of the weld to the Head and the Part1 to the Eye.
And from now on you should tween the C1 of the weld which stands for the CFrame
of Part1

And bam you’re only tweening the eye!

Yes, only the eye
image
image
image
I did this to both eyes btw

local model = workspace.Model
local eye = model.pB
local base = model.pA
local weld = base.Weld -- Part0 is base, Part1 is eye
local looking = workspace.LookAtPart

_G.stare = true
while _G.stare do
	wait()
	local newCF = CFrame.lookAt(eye.Position, looking.Position, Vector3.new(0,1,0))
	-- weld.Part0.CFrame * weld.C0 = weld.Part1.CFrame * weld.C1
	weld.C1 = newCF:Inverse()*weld.Part0.CFrame*weld.C0
end

I got this code to work.

1 Like