I understand that there are other posts like this but none of them seemed to help me. In short, I have an arrow Model and I want it to face a part even when the character moves. However, I can’t seem to make it work.
Here is my current code:
script.Parent.MouseButton1Click:Connect(function()
local player = game.Players.LocalPlayer
local character = player.Character
local Part = game.Workspace.LookingAt
local Arrow: Model = game.ReplicatedStorage.Arrow:Clone()
Arrow.Parent = workspace
Arrow:PivotTo(character.HumanoidRootPart.CFrame)
local charAttachment = Instance.new("Attachment", character.HumanoidRootPart)
charAttachment.Name = "charAttachment"
charAttachment.Visible = false
local arrowAttachment = Instance.new("Attachment", Arrow.PrimaryPart)
arrowAttachment.Visible = false
local alignPosition = Instance.new("AlignPosition", Arrow)
alignPosition.MaxForce = 25_000
alignPosition.Attachment0 = arrowAttachment
alignPosition.Attachment1 = charAttachment
alignPosition.Responsiveness = 25
charAttachment.Position = Vector3.new(0,0,-7)
while wait() do
Arrow.PrimaryPart.CFrame = CFrame.new(Arrow.PrimaryPart.Position, Part.Position)
end
end)
I also have 2 weldconstraints to weld the 3 parts together inside the model.