I am trying to create a ray that goes in the direction of MoveDirection. I am using MoveDirection simply because it's based on the player's input rather than where the player is going. There aren't any errors but the ray is detecting parts when a part isn't even there!
Here's the script
local LocalPlayer = game.Players.LocalPlayer
local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
local RootPart = Character:WaitForChild("HumanoidRootPart")
local Mouse = LocalPlayer:GetMouse()
local AttackRay
local Hit,Pos
local IgnoreList = Character:GetChildren()
table.insert(IgnoreList,workspace.Bullet)
table.insert(IgnoreList,workspace.Environment.Ground)
game:GetService("RunService").RenderStepped:connect(function()
AttackRay = Ray.new(RootPart.Position,(Character:WaitForChild("Humanoid").MoveDirection*15)+ RootPart.Position)
Hit,Pos = game.Workspace:FindPartOnRayWithIgnoreList(AttackRay,IgnoreList)
if Hit then
print("Intercepted!")
end
end)
I am using a part that emits particles to show the direction of the ray so I can get a Visual representation of the rays Direction
Here is a clip of the problem (There is an error but it is a load error for a decal which is irrelevant)
Is there something wrong with my lines of code? Any help is appreciated

5 comments
Hmm wheres the code block for the particle?
I Noticed The After The if statement for Hit You Only told the script to print ("intercepted!") Is That Intentional?
its just a small ball in the workspace with a particle in it. I didn't use a script to create it
Yes. i didn't do much on the script since it wasn't working. I was going to add on to it when i resolved the issue
ive also tried the script without the particle emiter part