I've tried using the RPG Monster EXP/Gold script but it doesn't seem to work and I can't make sense of the FindFirstChild("creator") and tag.

My script is located in Workspace.Zed (which is responsible for spawning the zombies and initialises the leaderboard

My Zombies are located in ServerStorage and are cloned to the Workspace on load.

How can I add the script to my zombies, so that when I kill one, it adds a point to my leaderboard?

The script inside my Zombie model:

local Humanoid = script.Parent.Humanoid -- Change Enemy to the name of your Monsters Humanoid

function PwntX_X() 
	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.Kills.Value = Leaderstats.Kills.Value + 1 --How Much Money Given
				wait(0.1)
				script:remove()
			end 
		end 
	end 
end 
Humanoid.Died:connect(PwntX_X) 

and the script within workspace.Zeds

local playerLeaderstats = {}

game.Players.PlayerAdded:connect(function(player) -- We createa function that will execute when PlayerAdded fires.
	playerLeaderstats[player] = {}
	playerLeaderstats[player]["Kills"] = 0	
	local leaderstats = Instance.new("Model") -- We create a model
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player -- we parent the leaderstats object to the player
	
	local kills = Instance.new("IntValue")
	kills.Name = "Kills"
	kills.Value = playerLeaderstats[player]["Kills"]
	kills.Parent = leaderstats
end)

Thanks

2 comments

0

clone the script that when on death for the zombie will give you points... Clone that script into the zombie everytime it spawns in, so basically just spawn in the zombie first then clone the script into the zombie

0

I've put the script inside my Zombie model so that it should be created with each instance of Zombie. The problem however is that when I kill a zombie, it doesn't update the leaderboard accordingly. I'll edit my post with the script in question.