Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

un able to cast value to objects ray casting, issue?

not sure whats going on here wached a video, and did everything he did but seems, to not work I had it working, the first time but when I went to save studio crashed and didn't save,


local ray = Ray.new(script.Parent.Position,Vector3.new(0,100,0))

while wait(1) do
	local hit,position = workspace:FindPartOnRayWithIgnoreList(ray,(script.Parent))
	if hit then
		print(hit.Name)
		local p = Instance.new("Part",workspace)
		p.Anchored = true
		p.CFrame = CFrame.new(position)
		p.Size = Vector3.new(1,1,1)
		game:GetService("Debris"):AddItem(p,1)
	end
end

1 answer

✓ Accepted answer

Your error is when defining the ignore list for your raycast.

The method takes an array of objects to be ignored, and you provided it with a single object.

You'll need to change

workspace:FindPartOnRayWithIgnoreList(ray,(script.Parent))

to

workspace:FindPartOnRayWithIgnoreList(ray, {script.Parent})

Hopefully this works for you!

2 comments

0

thank you! i see what i did there, a simple error. that can cause everything to fail. thats alot waterisice!

0

Thank you! I didn't realize all I had to do was provide a table.

This discussion is preserved as it was. New answers, comments, and votes are closed.