function ontouch(part)
local h = part.Parent:findFirstChild("Humanoid")
if h ~= nil then
local plr = game.Players:GetPlayerFromCharacter(h)
if plr ~= nil then
game.Lighting.LinkedSword:Clone().Parent = plr.Backpack
end
end
end
script.Parent.Touched:connect(ontouch)
I suspect that the problem is in the local plr = game.Players:GetPlayerFromCharacter(h) line, but I'm not sure what I have done wrong. Please help me through this and be sure to explain your answer to me so that I know what the problem is in the future. Thank you!

3 comments
Try adding a Debounce.
@ TheContinentofEurope That's probably a good idea, but it's not the issue the person was having. They would've probably figured out they should use a debounce anyway, and if not, they could just post another question for that; they are very different issues after all.
Excellent explanation and answer. Great job!