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

Ray stops after a stud or two?

I'm still working on my speed detector, it was working fine, but since I started working on the orienting with vehicle, it started having an issue with stopping after a stud or two instead of doing the full ray. https://gyazo.com/ba1f1dca5f391e299b8fd6ebf628e351

function Speedcheck()
	local ray = Ray.new(tool.CFrame.Position, script.Parent.CFrame.LookVector)
	local part, position = workspace:FindPartOnRay(ray, tool)
		
		local beam = Instance.new("Part", workspace)
		beam.BrickColor = BrickColor.new("Bright red")
		beam.FormFactor = "Custom"
		beam.Material = "Neon"
		beam.Transparency = 0.25
		beam.Anchored = true
		beam.Locked = true
		beam.CanCollide = false
		
		local distance = (tool.CFrame.p - position).magnitude
		beam.Size = Vector3.new(0.3, 0.3, distance)
		beam.CFrame = CFrame.new(tool.CFrame.p, position) * CFrame.new(0, 0, -distance / 2)
	print(position)
	print(distance)
	local speed = part.Velocity.Magnitude


script.Parent.Parent.S1.SurfaceGui.TextBox.Text = string.sub(part.Velocity.Magnitude,1,3)
end

1 comment

0

also formfactor is deprecated, you can just not use it

1 answer

✓ Accepted answer

from the looks of it you are just missing putting the max distance on to the ray when creating it.

try doing something like this

 local ray = Ray.new(tool.CFrame.Position, script.Parent.CFrame.LookVector * 300)

*NOTE: it doesn't have to be 300 but whatever you want the max distance to be

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