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

Why is hit a nil value if i use FindPartOnRayWithIgnoreList?

Asked by
aazkao 787 Moderation Voter
6 years ago

Here is my code in a tool with a handle

01tool = script.Parent
02handle = tool:WaitForChild("Handle")
03 
04 
05tool.Equipped:Connect(function(mouse)
06    if mouse then
07        mouse.Icon = "rbxassetid://316279304"
08 
09tool.Activated:connect(function()
10        tool.Firing:Play()
11          local ray = Ray.new(tool.Handle.CFrame.p, (mouse.Hit.p -  tool.Part.CFrame.p).unit*300)
12 
13local hit, position = game.Workspace:FindPartOnRayWithIgnoreList(ray, {game:GetService("Players").LocalPlayer.Character,tool.Handle})
14--if i use just FindPartOnRay and ignore only the player it will work and hit will not be a null value??
15 
View all 27 lines...
0
Ah ok i actually found out its because im printing hit.name and not hit, which is weird because if i use FindPartOnRay and "print hit.name or hit" it works, but for FindPartOnRayWithIgnoreList you cannot print "hit.name", only hit. Well my problem is solved but i really want to understand why this is if anyone can explain to me aazkao 787 — 6y
0
Line 6 is useless. User#19524 175 — 6y
0
yeah forgot to remove it when im editing the code aazkao 787 — 6y

Answer this question