Finding the ending point of a raycast?
3 | local ray = Ray.new(Player.Character.HumanoidRootPart.Position, Player.Character.HumanoidRootPart.CFrame.lookVector * RANGE) |
5 | local part, endPoint = workspace:FindPartOnRay(ray, Player.Character) |
7 | BrickModel.Parent = workspace |
9 | BrickModel:SetPrimaryPartCFrame(part.CFrame * CFrame.new( 0 , 0 , 0 )) |
This script is meant to spawn BrickModel
where the RayCast hits but it gives this error:
Players.Player.Backpack.BrickPlacer:10: attempt to index local 'part' (a nil value)
Script 'Players.Player.Backpack.BrickPlacer', Line 10
NOTE: I edited the error to match the lines of code in this question.
Please Help.