What do you want to achieve? I want the arrow to be able to move anywhere around the character
What is the issue? The arrow only goes behind the character and I want it to be able to move it anywhere on the character. Video included
What solutions have you tried so far? I cant really find anything on the Developer Forums that could help me and I’m not sure what to do to achieve my goal
Here is the calculations I am using for the arrow currently
local function moveArrow()
while held == true do
local target = mouse.Target
if target ~= nil then
if target.Parent.Name == "CurrentRagdoll" then
local arrow = workspace.MapInstances:FindFirstChild("Arrow")
arrow.Position = mouse.Hit.Position -- Move arrow to part position
arrow.CFrame = arrow.CFrame + Vector3.new(0,0,-3) -- Offset
arrow.CFrame = CFrame.lookAt(arrow.Position, target.Position) -- Face towards part
arrow.CFrame = arrow.CFrame * CFrame.Angles(0,math.rad(90),0) -- Correct rotation
end
end
RunService.Stepped:Wait()
end
end
local function moveArrow()
while held == true do
local target = mouse.Target
if target ~= nil then
if target.Parent.Name == "CurrentRagdoll" then
local arrow = workspace.MapInstances:FindFirstChild("Arrow")
arrow.Position = mouse.Hit.Position -- Move arrow to part position
arrow.CFrame = arrow.CFrame + Vector3.new(0,0,-3) -- Offset
arrow.CFrame = CFrame.lookAt(arrow.Position, target.Position) -- Face towards part
arrow.CFrame = arrow.CFrame * CFrame.Angles(0,math.rad(360),0) -- Correct rotation
end
end
RunService.Stepped:Wait()
end
end
local function moveArrow()
while held do
local target = mouse.Target
if target and target.Parent.Name == "CurrentRagdoll" then
local arrow = workspace.MapInstances:FindFirstChild("Arrow")
if arrow then
arrow.Position = mouse.Hit.Position
arrow.CFrame = arrow.CFrame + Vector3.new(0, 0, -3)
arrow.CFrame = CFrame.lookAt(arrow.Position, target.Position)
end
end
RunService.Stepped:Wait()
end
end
Try to create a reference point that is made from firing a ray starting from the camera position and ending on the surface of the character. This way you can create an arrow that is positioned and facing in a direction relative to the HumanoidRootPart or UpperTorso.
thanks! switched to using raycasting and it worked
local RunService = game:GetService("RunService")
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
local held = false
local function moveArrow()
while held == true do
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Whitelist
raycastParams.FilterDescendantsInstances = {workspace.MapInstances:FindFirstChild("CurrentRagdoll")}
raycastParams.IgnoreWater = true
local unitRay = mouse.UnitRay
local raycastResult = workspace:Raycast(unitRay.Origin, unitRay.Direction * 1000, raycastParams)
if raycastResult then
local target = raycastResult.Instance
local arrow = workspace.MapInstances:FindFirstChild("Arrow")
arrow.Position = raycastResult.Position
arrow.CFrame = CFrame.lookAt(arrow.Position, target.Position)
arrow.CFrame = arrow.CFrame * CFrame.new(0,0,1.5)
arrow.CFrame = arrow.CFrame * CFrame.Angles(0,math.rad(90),0)
end
RunService.Stepped:Wait()
end
end
mouse.Button1Down:connect(function()
held = true
moveArrow()
end)
mouse.Button1Up:connect(function()
held = false
end)