Okay so I am making a bow that shoots a beam once fired. The local script that fires the bow works but the damage script isn't working. The damage script is not a local script. I am using mouse.Target to determine what happens. Here is the damage script:
local playerName = script.Parent.Parent.Parent.Name
print(playerName)
local player = game:GetService("Players"):FindFirstChild(playerName)
local mouse = player:GetMouse()
script.Parent.Activated:Connect(function()
local humanoid = mouse.Target.Parent:FindFirstChild("Humanoid")
if humanoid then
humanoid:TakeDamage(10)
end
end)
I put this in the local script at first and it was just fine but as soon as I made it its own script it wouldn't work. There are no errors I am just really confused. Thanks in advance!

3 comments
There is an error message actually: Players.TheHideousGloom.Backpack.Bow.Script:6: attempt to index nil with 'Target'
try reading up on this: https://developer.roblox.com/en-us/api-reference/property/Mouse/Target
instead of doing :findfirstchild() do Mouse.Target filter