I'm trying to make a gun right now. When ever i click it just leaves me with this error: attempt to index nil with 'Target'"
local db = false --debounce script.Parent.Equipped:Connect(function() --when its equipped local player = game.Players:FindFirstChild( script.Parent.Parent.Name) --player local character = player.Character --players character local Handle = script.Parent.Handle --the tools handle local Fire = script.Parent.Particles.FirePart.Fire --the particle for when you fire the gun script.Parent.Activated:Connect(function() --when clicked if db == false then --debounce db = true local mouse = player:GetMouse() print(mouse.Target.Name) --error --still writing some code here wait(1) db = false --setting the debounce back to false after 1 second end end) end)
Add a check if Target isn't nil
if mouse.Target ~= nil then print(mouse.Target.Name) end