When I kill the NPC, it gives me EXP in solo test mode, but when I play it with more than 1 player it doesn't give me EXP. Am I suppose to load something?

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
				player.leaderstats.EXP.Value = player.leaderstats.EXP.Value + 16
			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)

2 comments

0

You have to identify each player.

0

Also if I put this in a local script it works