Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to make a NPC give exp to u? t(this title says me to say alot of words so i saying more?

I want to make my npc give me exp but i keep trying everything and nothing works i wanna ask how will u make a tag on the player so only the players who hit gets exp when the npc dies? can u tell me?

5 comments

0

To figure out who killed the NPC you can take a look at this thread: https://scriptinghelpers.org/questions/26480/is-there-a-way-to-find-out-who-killed-a-playernpc

0

Then using the NPC.Humanoid.Died event you can award the xp to the player

0

Then add the number of XP they got to the leaderstat/variable you are using.

0

I recommend putting a value inside of your sword, and when it's activated and it touches a player (check for humanoid) change the name and if the target player's humanoid is 0, then reward the XP to the player who killed them.

0

at least give some sort of example that you've tried..

1 answer

If you are making some kind of a sword or something, put this script inside of the sword part

script.Parent.Touched:Connect(function(touched)
	local Human = touched.Parent:FindFirstChild("Humanoid")
	if Human then
		if Human.Health >= 1 then
			local Player = game.Players:FindFirstChild(script.Parent.Parent.Parent.Name)
			if Player then
				local stats = Player.leaderstats:FindFirstChild("XP")--Name of currency
				stats.Value = stats.Value + 10--Amount to give per kill
			end
		end
	end
end

Hopefully this helps you come up with an idea! If you have any questions, comment below!

Best,

TheLastHabanero

3 comments

0

dude its a kick script i dont use sword

0

im making like a magic game with kicks and physical owees so this wont really help much XD

0

Just put this in the players leg then lol. It works for anything. Just make sure to add a separate damage script :)

This discussion is preserved as it was. New answers, comments, and votes are closed.