As the title said, how i can convert the old deprecated raycast to the new one?
This is my current script
connection = game:GetService("RunService").Heartbeat:Connect(function()
local ray = Ray.new(script.Parent.Position, Vector3.new(0, -1, 0) * 5) -- es * 10
local hitPart, hitPos = workspace:FindPartOnRay(ray)
if hitPart and hitPart.CanCollide and not hitPart:FindFirstChild("KnifeValue") and not hitPart:FindFirstChild("FloorValue") then
print(hitPart.Name)
script.Parent.CFrame = CFrame.new(hitPos, hitPart.Position)
script.Parent.Anchored = true
if hitPart.Parent:FindFirstChildWhichIsA("Humanoid") then
local hum = hitPart.Parent:WaitForChild("Humanoid")
hum:TakeDamage(10)
CreateSound(186311262, 1, 1, hitPart) EmitParticle(particle2, 1) -- EmitParticle(particle1, 1)
end
connection:Disconnect()
end
end)