Weird bug where specific tower model doesn't look at enemies right

So i’ve been making a TD game and have imported a tower model i made Via blender. However when i use it unlike every single other tower i have which were made a “PlaceHolders” in roblox.

This is my orientate function and it seems to work fine with every single other tower:

– Utility function to orient the tower to face a target, limited to XZ rotation
function OrientTowerToTarget(newTower, target)
if not (newTower and target) then return end

-- Ensure the tower and target have a HumanoidRootPart to calculate orientation
local towerRoot = newTower:FindFirstChild("HumanoidRootPart")
local targetRoot = target:FindFirstChild("HumanoidRootPart")

if towerRoot and targetRoot then
	-- Calculate the flat direction (XZ plane) from the tower to the target
	local towerPosition = towerRoot.Position
	local targetPosition = targetRoot.Position

	-- Zero out the Y components to constrain rotation to XZ plane
	local flatDirection = Vector3.new(targetPosition.X - towerPosition.X, 0, targetPosition.Z - towerPosition.Z).Unit

	-- Create a CFrame that points from the tower's position towards the target's position on the XZ plane
	local lookAt = CFrame.lookAt(towerPosition, towerPosition + flatDirection)

	-- Set the BodyGyro or tower's CFrame to orient it towards the target
	if towerRoot:FindFirstChildOfClass("BodyGyro") then
		towerRoot.BodyGyro.CFrame = lookAt
	else
		-- Fallback in case BodyGyro doesn't exist
		towerRoot.CFrame = lookAt
	end
end

end

However specifically with the Blender model instead of looking directley at the enemy, it looks directly away, i’ve tried re rigging it, editing the script, switching and swapping things left right and centre but it always seems to look directley away

Here is an example: Take this Placeholder tower shooting the enemies


It looks directley at them as it’s attacking.

Now take the Model:



For some reason unknown to me it shoots away from the enemies, which i am just at a complete dead end as to why this is happening. So i’ve came here if anyone has any idea why this is happening and how to fix it, please do as this bug is basically halting development

2 Likes

maybe it’s because your enemy is “reversed”? if that makes sense

essentially the front of the enemy is actually the back, and so on

1 Like

I’ll see if that’s the issue, bit weird that it only effects one tower tho if it’s correct. I’ve checked all the enemies and chyecked the orientation and they all are the same at start at 0,0,0 so i don’t think it’s the issue, Unless you didn’t mean the CFrame orientation?

1 Like

try rotating the HRP of the tower,

local lookAt = CFrame.lookAt(towerPosition, towerPosition + flatDirection) * CFrame.Angles(0,math.rad(180),0)

Yup that works, now whilst yes it does mean that now the placeholder tower attack looking away, that’s fine since A.They’ll be replaced B. I use the same orienatation of the rig in all my models so hopefully, for now that works, Thanks!

1 Like

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