I have this turret, and I want to make it look at the mouse. This works perfectly if it's only one part. So I tried welding the extra parts on and that didn't work(Stupidly).
So now I've deiced to use a model rotater, but I can't figure how how to make the model point towards the mouse.Hit.p
--Rotate model function
local function RotateModel(model,center,axes)
local origin={}
for _,child in pairs(model:GetChildren()) do
if child:IsA"BasePart" then
origin[child]=center:toObjectSpace(child.CFrame)
end
end
center=center*CFrame.fromEulerAnglesXYZ(unpack(axes))
for part,cf in pairs(origin) do
part.CFrame=center:toWorldSpace(cf)
end
end
RotateModel(MODEL,MODEL:GetModelCFrame(),{math.rad(90),math.rad(90),math.rad(90)}) -- Calling the function
--What I'm currently useing
cannon.Main.CFrame=CFrame.new(cannon.Main.Position,mouse.Hit.p) |