Raycast when Collision Issues

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want, when a part collides to something, to make a raycast from the part to the direction the part is going to detect if the collision was in front of it.
  2. What is the issue? Include screenshots / videos if possible
    I made a print to see if it works but it doesn’t print… here is the script:
script.Parent.Touched:Connect(function(collisionPart)

	local raycastParams = RaycastParams.new()
	print("c")

	local raycast = workspace:Raycast(script.Parent.Position , script.Parent.Velocity, raycastParams)

	if raycast then
		print("r")
	end
end)

here is a gif:
Enregistrement de l’écran 2023-10-24 à 12.04.21

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I read again the documentation, and tried to replace Velocity by Vector3.new(0,-1,0)as the part is falling down, to see if velocity was the problem. Anyone has an idea? Thank you in advance.
    tried adding this:

	raycastParams.FilterDescendantsInstances = {script.Parent}
	raycastParams.FilterType = Enum.RaycastFilterType.Exclude

found the solution by multiplying the velocity * 100
i dindt know direction was also the end of the raycast

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.