I'm trying to make a weapon that once it kills a player it will give it points. I have a script that will do that but it only works on linked swords that tag the player. I tried putting the tagging part of that script into my own but it ends up crashing the game and saying "attempt to call global 'tagHumanoid' (a nil value), line 10" I'm not sure what is happening...
local script
wait(0.01)
local CanDamage = true
local plr = game.Players.LocalPlayer
while true do
wait(0.01)
script.Parent.Touched:connect(function(hum)
if hum and hum.Parent:FindFirstChild("Humanoid") then
if CanDamage == true then
tagHumanoid(hum, plr)
CanDamage = false
hum.Parent.Humanoid:TakeDamage(10)
plr.swordlvl.Value = plr.swordlvl.Value + 2
wait(0.8)
untagHumanoid(hum)
CanDamage = true
end
end
end)
end
function tagHumanoid(humanoid, player)
local creator_tag = Instance.new("ObjectValue")
creator_tag.Value = player
creator_tag.Name = "creator"
creator_tag.Parent = humanoid
end
function untagHumanoid(humanoid)
if humanoid ~= nil then
local tag = humanoid:findFirstChild("creator")
if tag ~= nil then
tag.Parent = nil
end
end
end

3 comments
Thank you! Sorry for the poor indentation, I'll make sure to take care of that in the future.
No problem.
Also, something I'm only just now noticing.. It doesn't seem like the while loop is even necessary.