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

unable to cast string to bool while using raycasting?

local hit = workspace:FindPartOnRayWithIgnoreList(ray,"Blood","Hair","lefthand","righthand")

so i am using raycasting and there is an error with the findpart on ray i can show you guys the rest of the scripts but i am pretty sure the problem is with this

3 comments

0

Why do you have "Blood" between hair and the ray?

0

they are the things i want the ray to ignore

0

that is where you put them right?

1 answer

✓ Accepted answer

That is not what you use workspace:FindPartOnRayWithIgnoreList(). There's 4 parameters with workspace:FindPartOnRayWithIgnoreList() The 1st parameter is ray itself, the 2nd parameter is what to ignore, the 3rd parameter is terrain cells are cubes (I know, that kinda bothers me as well), and the 4th parameter is to ignore water.

Put your data on a table. Make sure you ignore the player.Character. I'm assuming you're using remote events.

local data = {
	player.Character, --You need to ignore the character from hitting itself.
	"blood", --I do not recommend using strings.
	"hair",
	"lefthand",
	"righthand"
}

Secondly, use workspace:FindPartOnRayWithIgnoreList() properly.

local part, position = workspace:FindPartOnRayWithIgnoreList(ray, Data, true, false)

The reason I used part, position is because it will make your life a lot easier when creating 'beams' and also finding other characters.

3 comments

0

cool thanks also do you have to have all four parameters?

0

You don't have to use all 4 parameters, I think. Parameter 1 is the only necessary one, and Parameter 2 should be used. Edit: Only for FindPartOnRay. FindPartOnRayWithIgnore requires the 2nd parameter.

0

ok thx

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