Prints nil and I'm surrounded by parts.
01 | local char = workspace:WaitForChild( "papasherms" ) |
02 | local newRay = Ray.new( |
03 | char:GetPrimaryPartCFrame().p, |
04 | (char:GetPrimaryPartCFrame().p - (char:GetPrimaryPartCFrame() * CFrame.new(char.PrimaryPart.Size.X/ 2 , 0 , 0 )).p).unit * 500 |
05 | ) |
06 |
07 | spawn( function () |
08 | while (wait( 1 )) do |
09 | local hit, pos, normal = workspace:FindPartOnRay(newRay, char) |
10 | print (hit) |
11 | end |
12 | end ) |
I think you should use a LocalScript, put a LocalScript inside StarterPlayer > StarterCharacterScripts
, and paste this:
01 | local Player = game:GetService( "Players" ).LocalPlayer |
02 | local Character = Player.Character |
03 |
04 | spawn( function () |
05 | while wait( 1 ) do |
06 | --tuple FindPartOnRay( Ray ray, Instance ignoreDescendantsInstance, bool terrainCellsAreCubes, bool ignoreWater ) |
07 | local Hit, Pos, Normal = workspace:FindPartOnRay( |
08 | Ray.new( |
09 | Character.HumanoidRootPart.Position, |
10 | Character.HumanoidRootPart.CFrame.lookVector * 500 |
11 | ), |
12 |
13 | Character |
14 | ) |
15 |
16 | print (Hit, Pos, Normal) |
17 | end |
18 | end ) |
Now, please read the script carefully and try to understand what's going on, this might help you in the future. Hope this helped!