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

Linking Roblox Guns to Kills on leaderboard - How would I go about this?

So I've been using the "Leaderboards" Script Roblox released, along with many of these guns Roblox released for use (Here's an example: https://www.roblox.com/library/4842207161/Auto-Rifle ). I'm really new to learning scripting, and I've watched SEVERAL videos to this point trying to find out how to link the damage/kills from these guns to add a +1 to the "kills" stat of a player on the leaderboard. These guns don't have a "creator" tag, or "tagHumanoid" tags for me to try to get any sort of lead on, I think the "BulletWeapon" is the tag for what does the damage... I think. I can't find where I'd put the "creator" tag like I'm supposed to in the videos, because nothing seems to match up with what they videos or tutorials are describing, I'm sorry if this isn't an appropriate question for this site, but could someone point me in the right direction here? I should probably be trying to find a way to add the "creator" tag to them, to link them to the leaderboard, right? When I've tried it just breaks the gun, though

function TagHumanoid(humanoid, player)
 local Creator_Tag = Instance.new("ObjectValue")
 Creator_Tag.Name = "creator"
 Creator_Tag.Value = player
 Debris:AddItem(Creator_Tag, 2)
 Creator_Tag.Parent = humanoid
end

and

function UntagHumanoid(humanoid)
 for i, v in pairs(humanoid:GetChildren()) do
  if v:IsA("ObjectValue") and v.Name == "creator" then
   v:Destroy()
  end

those are the two codes it's telling me to fidget with, and for reference this is the leaderboard I'm trying to link it to https://www.roblox.com/library/53310/Leaderboard

1 answer

Go in the gun script and look for the line of code that damages the player. Under that write a line of code that checks if the players health is < 1 and if it is it will add +1 kill to the player. Should look something like this:

-- line where it does damage
if hit.Health < 1 then
player.leaderstats.Kills.Value = player.leaderstats.Kills.Value + 1
else
print("Health >= 1")

1 comment

0

And then would I have to try and make it find the killer to add the +1 to their board or something?

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