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