Raycasting tool not working

  1. What do you want to achieve?
    I’m trying to make a fire hose system where you can click on a tool and it fires a ray out for a part. It should then look (with a filter so it only looks in a folder) to find out if it’s hit something. At this moment all I want it to do after that is print out the part’s name.

  2. What is the issue?
    Upon getting the rays working in a stationary object, I moved it over to the tool and added an activated script and for loop. Somehow, it has now stopped working. I may be overlooking something simple, however I think it’s best I get a fresh person’s eyes to look over this.

  3. What solutions have you tried so far?
    I’ve tried different filters for it, make it so it has no filters (it picked up some things but they were random).

local Origin = script.Parent.Handle.RayPart
local Direction = Origin.CFrame.LookVector * 100
local Parameters = RaycastParams.new()
local Enabled = false

Parameters.FilterDescendantsInstances = {workspace.FireParts}
Parameters.FilterType = Enum.RaycastFilterType.Whitelist

script.Parent.Activated:Connect(function()
	Enabled = true
	script.Parent.Handle.Emmiter.ParticleEmitter.Enabled = true
	while Enabled == true do
		local RaycastResult = workspace:Raycast(Origin.Position, Direction, Parameters)

		if RaycastResult then
			print(RaycastResult.Instance)
		end
		wait(0.3)
	end
end)

script.Parent.Deactivated:Connect(function()
	Enabled = false
	script.Parent.Handle.Emmiter.ParticleEmitter.Enabled = false
end)

This is my script I’m using, it’s inside the tool.


This is the part that the ray casts from, it’s at an angle to match with the particles that come out. When walking around with it, everything seems to activate fine however it won’t pick up any of the parts in my folder even if I point it right at it.