Hey guys. I was working on making a raycast that would print whatever object it touched, but I don’t know much about raycasting. Mind helping me out? If not, thanks a bunch!
local function CreateRay()
local WorkSpace = game:GetService("Workspace")
local Camera = Workspace:FindFirstChild("Camera")
local Baseplate = Workspace:FindFirstChild("Baseplate")
if Camera and Baseplate then
local RayParams = RaycastParams.new()
RayParams.RespectCanCollide = true
local Raycast = WorkSpace:Raycast(Camera.Focus.Position, game.Workspace.Baseplate.Position, RayParams.RespectCanCollide)
-- Not sure what else to put here. Should I change anything?
end
end
local function CreateRay()
local Camera = workspace:FindFirstChild("Camera")
local Baseplate = workspace:FindFirstChild("Baseplate")
if Camera and Baseplate then
local RayParams = RaycastParams.new()
RayParams.RespectCanCollide = true
local Raycast = workspace:Raycast(Camera.Focus.Position, workspace.Baseplate.Position, RayParams.RespectCanCollide)
if not Raycast then print("Nothing was hit...") return end
print(Raycast.Instance.Name..":", Raycast.Instance:GetFullName())
end
end