local RANGE = 5
local ray = Ray.new(Player.Character.HumanoidRootPart.Position, Player.Character.HumanoidRootPart.CFrame.lookVector * RANGE)
local part, endPoint = workspace:FindPartOnRay(ray, Player.Character)
BrickModel.Parent = workspace
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.
