Hello, I made a turret for my firetruck and it works perfectly when its not rotated but when I rotate the vehicle its not working properly what can I do ?
local TS = game:GetService("TweenService")
local TI = TweenInfo.new(.1)
local function point(position)
local joint = workspace.FireTruck.Body.Part.Motor6D
local worldC0 = CFrame.new(joint.Part0.CFrame.X,0,joint.Part0.CFrame.Z)* joint.C0
local cf = CFrame.new(Vector3.new(worldC0.X,0,worldC0.Z), position) * CFrame.Angles(math.rad(180),math.rad(180),math.rad(90))
local goal = {}
goal.C0 = ((cf - cf.p) + joint.C0.p) * CFrame.Angles(0,-math.pi / 2, -math.pi / 2)
local asd =TS:Create(joint,TI,goal)
asd:Play()
end
while wait(0.1) do
point(Vector3.new(workspace.Target.Position.X,0,workspace.Target.Position.Z))
end