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

Raycast Not Working Properly?

Asked by 3 years ago
Edited 3 years ago

Whenever i run this it says "Ray Hit Nothing" I am trying to make it print what the camera is facing

camera = workspace.CurrentCamera
player = game.Players.LocalPlayer
character = game.Workspace:WaitForChild(player.Name)

local function Shoot(start, direction)
    local rayParams = RaycastParams.new()
    rayParams.FilterDescendantsInstances = {character}
    rayParams.FilterType = Enum.RaycastFilterType.Blacklist
    local ray = workspace:Raycast(start, direction, rayParams)
    if ray then
        print(ray.Instance)
    else
        print("Ray Hit Nothing")
    end
end

while true do
    Shoot(camera.CFrame.Position, camera.CFrame.LookVector)
    wait(1)
end
0
Do you realize Player.Character is a thing:P Ziffixture 6913 — 3y
0
Yeah for me though I find it easier to use waitforchild player.name Is there I important reason to use player.character instead? CubicleHead -3 — 3y

Answer this question