I’m trying to rotate this arrow around my lowertorso, but it’s not working too well.
Here’s an example of what I’m trying to achieve:
https://gyazo.com/c05c911c0f3d22a47265e553a8bf517c
Here’s what I have right now:
https://gyazo.com/90fac79cdc2d01a45ff272f1323c2c8c
Here’s the code:
local player = game:GetService('Players').LocalPlayer
local character = player.CharacterAdded:Wait()
local HumanoidRootPart = character:WaitForChild('HumanoidRootPart')
local Mouse = player:GetMouse()
local camera = workspace.CurrentCamera
local Cursor = game:GetService('ReplicatedStorage'):WaitForChild('Models'):WaitForChild('Cursor')
local WorkCursor = workspace:WaitForChild('Cursor')
local Arrow = Cursor:WaitForChild('Arrow')
local Circle = Cursor:WaitForChild('Circle')
local Line = Cursor:WaitForChild('Line')
local MOUSE_DOWN = false
local MOUSE_X
local MOUSE_Z
Line.Parent = WorkCursor
Arrow.Parent = WorkCursor
Circle.Parent = WorkCursor
Mouse.Move:Connect(function()
if MOUSE_DOWN then
MOUSE_X = Mouse.Hit.Position.X
MOUSE_Z = Mouse.Hit.Position.Z
end
end)
Mouse.Button1Down:Connect(function()
MOUSE_DOWN = true
end)
Mouse.Button1Up:Connect(function()
MOUSE_DOWN = false
end)
while task.wait() do
local pos = Vector3.new(HumanoidRootPart.Position.X, 17, HumanoidRootPart.Position.Z - 2)
if MOUSE_X and MOUSE_Z then
Line.CFrame = CFrame.lookAt(pos, Vector3.new(MOUSE_X, 17, MOUSE_Z)) * CFrame.fromEulerAnglesXYZ(0, math.rad(180), 0)
else
Line.CFrame = CFrame.new(pos) * CFrame.fromEulerAnglesXYZ(0, math.rad(180), 0)
end
Arrow.CFrame = Line.CFrame * CFrame.new(0, Line.Size.y/2 - .28, Line.Size.z - 1)
local raycastparams = RaycastParams.new()
raycastparams.FilterType = Enum.RaycastFilterType.Exclude
raycastparams.FilterDescendantsInstances = {character, Arrow, Line, Circle, game:GetService('CollectionService'):GetTagged('ShootingZone'), game:GetService('CollectionService'):GetTagged('Barrier')}
local result = workspace:Raycast(Line.Position, Line.CFrame.LookVector * -100, raycastparams) -- Raycast 10 studs forward
if result and result.Instance.Parent then
if result.Instance:IsA('BasePart') then
if game:GetService('CollectionService'):HasTag(result.Instance.Parent, 'Block') then
Circle.Position = Line.Position * Line.CFrame.LookVector * -1
end
end
end
end