Why does it say in output: "17:13:42.515 - Value is not a valid member of Model", "17:13:42.515 - Script 'Workspace.Player1.StarterSword.Handle.LocalScript', Line 13", and "17:13:42.515 - Stack End". The NPC has the value inside of him. How can I fix this?
local debounce = false
local player = game.Players.LocalPlayer
function onTouched(hit)
if not debounce then
debounce = true
if hit.Parent.Name:sub(1,17) == "AFK Noob Lv 1 HP " then
hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - 25
if hit.Parent.Humanoid.Health == 0 then
if hit.Parent.Value == false then
player.leaderstats.EXP.Value = player.leaderstats.EXP.Value + 16
end
hit.Parent.Value = true
end
wait(0.5)
debounce = false
elseif hit.Parent.Name:sub(1,4) == "Noob" then
hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - 25
wait(0.5)
debounce = false
end
end
end
script.Parent.Touched:connect(onTouched)
