Hey everyone! Me and @LordDogFood are trying to make a turret look at the part, which is a stand in for some AI. For some reason, it will not look at the part. Our code is below, any help is appreciated!
game:GetService("RunService").RenderStepped:Connect(function()
for i, v in pairs(workspace:GetChildren()) do
if v.Target.Value then
local cf = CFrame.new(v.Movement.MP.C0.p, v.Target.Value.CFrame.p)
v.Movement.MP.C0 = cf
end
end
end)
Maybe add a print statement to check if the cframe code is even running.
game:GetService("RunService").RenderStepped:Connect(function()
for i, v in pairs(workspace:GetChildren()) do
if v.Target.Value then
print("cframe working")
local cf = CFrame.new(v.Movement.MP.C0.p, v.Target.Value.CFrame.p)
v.Movement.MP.C0 = cf
end
end
end)
We know its running because dogfood made the turret go helicopter in that if statement
What do you mean by “turret go helicopter,” can you show a video of it?
It was a test to make sure it was working otherwise, we just have an issue making a motor6D face an object.
Solved.
game:GetService("RunService").RenderStepped:Connect(function()
for i, v in pairs(workspace.Defences:GetChildren()) do
if v.Target.Value then
local l = v.Movement.CFrame:ToObjectSpace(CFrame.new(v.Movement.CFrame.p,v.Target.Value.CFrame.p))
v.Movement.MP.C1 = v.Movement.MP.C1*l
end
end
end)