Model moves when I try to rotate it in game

I’m trying to make it so that my tower is facing the target its attacking, but when I do it the part just moves around, like here:

robloxapp-20230702-2352330.wmv (2.9 MB)

as you can see it just phases through the thing, i want it so it doesn’t phase through and just stays and rotates in one place, heres the code if you want

local targetCFrame = CFrame.lookAt(newTower.HumanoidRootPart.CFrame.p, target.PrimaryPart.Position*Vector3.new(1,0,1) + Vector3.new(0,newTower.HumanoidRootPart.CFrame.Y,0))
		newTower.HumanoidRootPart.CFrame = targetCFrame
		newTower.HumanoidRootPart.CFrame *= CFrame.new(1,0,1)

I’ve tried doing Piviot to or anchoring the parts but none of these work and i haven’t found any useful posts, please help me, thanks.

1 Like

HumanoidRootPart.CFrame.LookVector i think

1 Like

and how do i exactly implement that?

You’re moving the character though? *= CFrame.new(1,0,1) moves it on x and z axis

It’s easy, just do this:

local BatGuy = --the bat guy
local Enemy = --the enemy the bat guy is going to attack

BatGuy.CFrame = CFrame.Lookat(BatGuy.HumanoidRootPart.Position, Vector3.new(Enemy.HumanoidRootPart.Position.X, BatGuy.HumanoidRootPart.Position.Y, Enemy.HumanoidRootPart.Position.Z))

yeah, I don’t now how that got here, probably my stupidity, thank you!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.