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

How do make it so on each kill, I get +1 kill on leaderboard?

I'm editing the entire question: So I found this creator tutorial, but I have no idea where to put the script. Do i put it somewhere here?

if skp_0 then
		if skp_0.Team ~= SKP_0.Team or skp_0.Neutral then
			local skp_t	= Instance.new("ObjectValue")
			skp_t.Name	= "creator"
			skp_t.Value	= SKP_0
			skp_t.Parent= SKP_1
			game.Debris:AddItem(skp_t, 1)

			SKP_1:TakeDamage(skp_1)
			return;
		end;

		if not gameRules.TeamKill then return; end;
		local skp_t	= Instance.new("ObjectValue")
		skp_t.Name	= "creator"
		skp_t.Value	= SKP_0
		skp_t.Parent= SKP_1
		game.Debris:AddItem(skp_t, 1)

		SKP_1:TakeDamage(skp_1 * gameRules.TeamDmgMult)
		return;
	end

	local skp_t	= Instance.new("ObjectValue")
	skp_t.Name	= "creator"
	skp_t.Value	= SKP_0
	skp_t.Parent= SKP_1
	game.Debris:AddItem(skp_t, 1)

	SKP_1:TakeDamage(skp_1)
	return;
end

or here?

function UpdateLog(Player,humanoid)

	local tag = humanoid:findFirstChild("creator")

	if tag ~= nil then

		local hours = os.date("*t")["hour"]
		local mins = os.date("*t")["min"]
		local sec = os.date("*t")["sec"]
		local TagType = tag:findFirstChild("type")

		if tag.Value.Name == Player.Name then
			local String = Player.Name.." Died | "..hours..":"..mins..":"..sec
			table.insert(CombatLog,String)
		else
			local String = tag.Value.Name.." Killed "..Player.Name.." | "..hours..":"..mins..":"..sec
			table.insert(CombatLog,String)
		end

		if #CombatLog > 50 then
			Backup = Backup + 1
			warn("ACS: Cleaning Combat Log | Backup: "..Backup)
			warn(CombatLog)
			CombatLog = {}
		end
	end
end

2 answers

Make a script in ServerScriptService, and when a player died, it will check if it has a creator tag inside its Humanoid. And if it does, it will add kills to the player who killed them.

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(Player)
   Player.CharacterAdded:Connect(function(Character)
      local Humanoid = Character:WaitForChild("Humanoid")
      
      Humanoid.Died:Connect(function()
         local Tag = Humanoid:FindFirstChild("creator")
         
         if Tag and Tag:IsA("ObjectValue") and Tag.Value then
            local otherPlayer = Tag.Value
            local otherLeaderstats = otherPlayer:WaitForChild("leaderstats")
            
            otherLeaderstats:WaitForChild("Kills").Value += 1
         end
      end)
   end)
end)

5 comments

0

sry to say, it doesn't work :/

0

but i tested it on npc so that might mean something?

0

and im using r6 models

0

oh, this only works for real players, not npcs. do u want me to also make a scropt for npcs too?

0

also do you have a leaderstats folder in the player?

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