Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Trying to launch a ray from players left arm help?

Asked by
iLordy 27
4 years ago

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

1 answer

Log in to vote
1
Answered by 4 years ago

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
0
Okay that stops the error but it seems my ray is not casting. iLordy 27 — 4y
Ad

Answer this question