Im trying to learn raycast functions for a practice gun model but I keep recieving the error, any ideas on how to fix it, heres my code:
local mouse = game.Players.LocalPlayer:GetMouse()
local handle = script.Parent
function shootRay()
local startPos = handle.Parent.PrimaryPart.Position
local endPos = startPos + handle.Parent.PrimaryPart.CFrame:vectorToObjectSpace(Vector3.new(1, 0, 0))
local ray = Ray.new(startPos, endPos)
local result = game.Workspace:Raycast(ray, 100) --Line receiving the Error
if result.Hit then
local humanoid = result.Hit:FindFirstChild("Humanoid")
if humanoid then
humanoid:TakeDamage(10)
end
end
end
mouse.Button1Down:Connect(function(plr)
shootRay()
end)
P.S. Im just getting back into scripting after a long time, so please bear with me
