Raycast not working

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!
    A raycast that goes from the player towards the direction its looking
  2. What is the issue? Include screenshots / videos if possible!
    it seems the raycast is fired from another part when i told it to fire from the humanoidrootpart
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    i’ve tried watching videos but i didnt find much…
local rayresults = {}
    local origin = plr.Character:FindFirstChild("HumanoidRootPart").Position
    local direction = (plr.Character:FindFirstChild("HumanoidRootPart").RayAttachment.WorldPosition - origin).Unit * 100
    while task.wait(0.1) do
        rayresults = workspace:Raycast(origin, direction)
        print(rayresults,"RAYCASTED",origin,":: ::",direction)
        if rayresults then
            rayresults.Instance.Transparency = 0.5 
        end
    end

this is what it prints out
image
but if i go to this specific place


attachment position:

image

The origin and direction variables should be defined within the loop to account for player movement.

1 Like

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