RightVector not working with RayCast

my goal is to make very basic generating terrain here is my code

Note: The setParams() Function just sets a Size, Anchored boolean, And a Color (im very lazy)

for i = 1,100 do
	local ray = Ray.new(Part.Position,Part.CFrame.RightVector * 50)
	if not workspace:FindPartOnRay(ray,Table[i]) then
		local Par = Instance.new("Part",workspace)
		table.insert(Table,Par)
		Par.Name = "Fart1"
		setParams(Par)
		Par.CFrame = Part.CFrame * CFrame.new(0,0,32)
	end
	local ray = Ray.new(Part.Position,Part.CFrame.RightVector * 50)
	if not workspace:FindPartOnRay(ray,Table[i]) then
		local Par = Instance.new("Part",workspace)
		table.insert(Table,Par)
		Par.Name = "Fart"
		setParams(Par)
		Par.CFrame = Part.CFrame * CFrame.new(0,0,32)
	end
end

This works perfectly fine with lookVector and UpVector but for some reason whenever i use RightVector i just doesnt execute the code inside the if???

1 Like

What do you mean by RightVector?

Can you show me the full code? I’m trying to test the script.

Please provide more information. You’ve given us some code and told us it doesn’t work but we don’t know what that actually means.

  • Are there any errors in the output?
  • What is the expected result?
  • What is the actual result?
  • What is the result when using LookVector or UpVector?

So it has a table which for each part it creates it adds it to the table and then for each part it sends 4 rays and checks for parts

starts with this

And this is what i was able to create until i ran into the issue with when i try to use rightVector it simply does not execute the code shown under the if statement

Basically what im trying to do is for each one of these parts:

this is the result i got with lookVector


i am sending a ray left and right and checking for a part if there is not one it creates a part in a infinite loops in what my end goal will be procedurally generated terrain

and to what you said there is no errors no nothing it simply just does nothing

Hope this clears things up!

1 Like

Try using Face Selector Plugin and try debugging. Maybe you selected the wrong vector.

I think the reason why it does nothing is that it only offsets the position of the original part.

dont think so… im using exactly whats from the devforum

Thanks for helping me realize that mistake fixed that part… but still doesnt do anything i have been debugging with print() for a while and nothing

reminder: It works perfectly fine with lookVector just for some reason rightVector completely breaks with 0 errors

If it doesn’t work try to multiply i in the loop with the axis you want to change.

Let me reexplain because it doesnt seem like you understand

local ray = Ray.new(Table[i].Position,Table[i].CFrame.RightVector * 50)
	if not workspace:FindPartOnRay(ray,Table[i]) then
		print("d")
	end

This is thats being attempted to read the parts around it but nothing under the if not workspace:FindPartOnRay(ray,Table[i]) then runs regardless of anything

It looks like you’re raycasting to the right twice. You explained you wanted to do left and right if I interpreted correctly. Try setting the second portion to Part.CFrame.RightVector * -50 instead of Part.CFrame.RightVector * 50

Thing is, Neither works what so ever. Once again nothing under the if statement runs

Try putting it in a coroutine.
Edit: Nevermind, it does not work.

Try this:

for i = 1,100 do
	local ray = Ray.new(Part.Position,Part.CFrame.RightVector * 50)
	if not workspace:FindPartOnRay(ray,Table[i]) then
    	local Par = Instance.new("Part",workspace)
    	local Par2 = Instance.new("Part",workspace)
    	table.insert(Table,Par)
		table.insert(Table,Par2)
    	Par.Name = "Fart1"
    	Par2.Name = "Fart"
		setParams(Par)
		setParams(Par2)
		Par.CFrame = Part.CFrame * CFrame.new(0,0,i*32)
		Par2.CFrame = Part.CFrame * CFrame.new(0,0,i*-32)
	end
end

If it does not work outside, put it inside!

Nah man nothing :confused: aaaaaaa(charlimit)

For mine it works. (charlimit)

now it works after i remove the lookvector part??? :confused:

I’m still not sure what your code is for but is any part blocking the ray? Try printing the ray result.