So I want it to not give EXP when the NPC has the Value, but it still gives EXP even though there is a value inside the NPC. Why is that? I am guessing on line 11 "if not", is suppose to be written differently?
local debounce = false
local objectValue = Instance.new("ObjectValue")
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 not player.Character:FindFirstChild('Value') then
player.leaderstats.EXP.Value = player.leaderstats.EXP.Value + 16
end
objectValue.Parent = hit.Parent
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)
