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

Whenever I kill this npc, it won't give me exp. I think something is wrong with my weapon?.

So, I'm a pretty new scripter and im making a script where the player kills an npc, he or she gains Exp and that exp can used to lvl up and unlock new fighting styles which hit more and harder, I feel like the problem is my weapon because it is a combat weapon that has fighting moves and animations and all that a combat system has, how would I make this script work for the player so when they kill the npc, they gain Exp

local Humanoid = script.Parent.Humanoid

function Dead()
	local tag = Humanoid:FindFirstChild("creator")
	if tag ~= nil then
		if tag.Value ~= nil then
			local leaderstats = tag.Value:FindFirstChild("leaderstats")
			if leaderstats ~= nil then
				leaderstats.Exp.Value = leaderstats.Exp.Value + 10
				wait(0.1)
				script:Remove()
			end
		end
	end
end
Humanoid.Died:Connect(Dead)

2 answers

On line 11, I don't think :Remove is a thing. Replace that with :Destroy()

1 comment

0

Nope, that didn't help

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