The problem is on line 10, when I try to get the name of the part. Output says that part is a nil value.
local tool = script.Parent local player = game.Players.LocalPlayer local mouse = player:GetMouse() script.Parent.Activated:connect(function() if mouse.Target.Name == "Water" then local ray = Ray.new(tool.Handle.Position, mouse.Target.Position) local part, point = workspace:FindPartOnRay(ray) if part.Name == "Water" then print "success" end end end)
Alright, here ye go. some help.
It simple to fix this problem.
Use:
local tool = script.Parent local player = game.Players.LocalPlayer tool.Equipped:Connect(function(mouse) mouse.Button1Down:Connect(function() local ray = Ray.new(tool.Handle.Position, mouse.Target.Position) local part, point = workspace:FindPartOnRay(ray) if part.Name == "Water" then print "success" end end) end)
I forgot somethings sorry, here have a smiley face :) .