I’ve been searching for an answer for hours on how to make the arrow look at the player correctly, and i can’t find anything.
The issue is that the arrow is somehow rotated and I can’t find anything to solve this.
I’ve tried looking for an answer using chatgpt, youtube videos and roblox devforum.
local newArrow = script.Parent.arrow.Handle:Clone()
newArrow.Parent = workspace
newArrow.Name = "ArrowClone"
newArrow.CanCollide = true
newArrow.Anchored = true
local object = newArrow
local speed = 5
local players = game:GetService("Players"):GetPlayers()
local pickedPlayer = players[math.random(1, #players)]
while true do
local playerPos = pickedPlayer.Character:FindFirstChild("HumanoidRootPart").Position
local objectPos = object.Position
local direction = (playerPos - objectPos).Unit
local distance = (playerPos - objectPos).Magnitude
if distance > 2 then
object.CFrame = CFrame.lookAt(object.Position, pickedPlayer.Character.HumanoidRootPart.CFrame.Position) -- if the code has a problem, i think it would be on this line. I'm not really experienced on CFrames yet.
object.Position = object.Position + direction * speed * math.min(distance, 1/60)
else
newArrow:Destroy()
break
end
wait()
end