Problem with Vector3 raycast

I am creating a spinning top system with these letters in each of these sectors here detecting the arrow that is spun and stopping at.

image_2022-09-12_165628857

I’m having a problem where I couldn’t get the raycast to detect the arrow part of the spinner. I’m utilizing Vector3.new to create the ray from a letter.

This script for Letter 1, as highlighted in the picture

local letter1 = script.Parent
local arrow = game.Workspace["Spinning Top"].spinnerarrow
local ray = Ray.new(letter1.Position, Vector3.new(-1, 1, 0))

while true do
	local hit, position = game.Workspace:FindPartOnRayWithIgnoreList(ray, {letter1})
	if hit then
		print("Letter 1 is hit")
	else
		print("Letter 1 is not hit")
	end
end

Is there something missing in my script or is there something wrong in it?

I’m assuming that you’re trying to cast a ray from the position of letter1 to a position above it, moved along on the X-axis?

Right now you’re casting a ray from a Vector3 of the position of letter1 to a Vector3 of -1, 1, 0 in the workspace. It could be the case that your spinner is not positioned in that part of the workspace, and instead you need to try something similar to the following:

local ray = Ray.new(letter1.Position, Vector3.new(game.Workspace:FindFirstChild("SpinnerPart").Position)

Just an idea, but let me know if it helps.

Ray.new and workspace:FindPartOnRayWithIgnoreList are deprecated. i suggest you use workspace:Raycast with RaycastParams

now for the problem i believe @anon_j1124 got it right