I'm currently trying to launch 2 different rays. One from the left arm of the characters arm in the -x direction and the on the right arm in the +x direction. I'm just practicing my raycasting I want the rays to print out the name of the objects it touches.
local Players = game:GetService("Players") local LocalPlayer = Players.LocalPlayer local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait() local LeftArm = Character["Left Arm"] local ray = Ray.new(LeftArm, Vector3(-35,0,0) * 500) local hit = workspace:FindPartOnRay(ray, Character) while true do print(hit) wait(0.1) end
So far I just started on the left arm. When I run the game it gives me an error saying attempt to call a table variable on line 6. Not sure what this means as I am pretty new to roblox scripting. If anyone could point me into a direction on how to start actually throwing a ray towards the direction of the left arm and having it print the name of the objects it catches, it would help me a ton. Thanks
hit won't always exist in your case, it could be breaking the script, do something like
if hit then print(hit) wait(0.1) end