Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Ray stops after a stud or two?

Asked by 6 years ago

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
0
also formfactor is deprecated, you can just not use it theking48989987 2147 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

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

Ad

Answer this question