The problem is on line 10, when I try to get the name of the part. Output says that part is a nil value.
01 | local tool = script.Parent |
02 | local player = game.Players.LocalPlayer |
03 | local mouse = player:GetMouse() |
04 |
05 |
06 | script.Parent.Activated:connect( function () |
07 | if mouse.Target.Name = = "Water" then |
08 | local ray = Ray.new(tool.Handle.Position, mouse.Target.Position) |
09 | local part, point = workspace:FindPartOnRay(ray) |
10 | if part.Name = = "Water" then |
11 | print "success" |
12 | end |
13 | end |
14 | end ) |
Alright, here ye go. some help.
It simple to fix this problem.
Use:
01 | local tool = script.Parent |
02 | local player = game.Players.LocalPlayer |
03 |
04 |
05 |
06 | tool.Equipped:Connect( function (mouse) |
07 |
08 |
09 | mouse.Button 1 Down:Connect( function () |
10 | local ray = Ray.new(tool.Handle.Position, mouse.Target.Position) |
11 | local part, point = workspace:FindPartOnRay(ray) |
12 | if part.Name = = "Water" then |
13 | print "success" |
14 | end |
15 | end ) |
16 |
17 | end ) |
I forgot somethings sorry, here have a smiley face :) .