I have a script that’s able to spin a cube around inside an NPC that shoots out raycasts it isn’t that effect since it kind of acts like a submarine sonar but I want to change this so the part looks directly at the player on the Y-axis instead of just spinning around stupidly
I’ve tried many different ways to achieve this but it hasn’t worked out well and it just either moves the NPC with it too or just doesn’t work at all. If anyone can assist me on what to do to solve this it would be great
here’s the script that works that spins the cube around the raycast stuff is in a separate one:
local tpart = script.Parent.Parent.Head
local cfpart = script.Parent
local NewNumber = 0
local w = Instance.new("Weld",tpart)
w.Part0 = tpart
w.Part1 = cfpart
local cf0 = tpart.CFrame
w.C0 = cf0:Inverse()
while task.wait(0.001) do
NewNumber -= 5
local cf1 = CFrame.new(-9872.459, 21060.545, -770.799) * CFrame.Angles(0, math.rad(NewNumber), 0)
w.C1 = cf1:Inverse()
end