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