Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

What is 'CreateTag(Attacker, VictimHumanoid)?

Asked by 9 years ago

My friend, he had a Anime game, he was EXTREMELY good at scripting, so he shut it down and allowed several people to copy it, and I did, so I started looking at scripts trying to figure out what this does, what that does, and by the Title, you can tell it's about Tag. Like, this COMPLETELY confuses me, I can read anything but this. Take a look at it, my eyes are watery :l.

function CreateTag(Attacker, VictimHumanoid)
 for i, v in pairs(VictimHumanoid:GetChildren()) do
  if v.Name == "creator" then
   v:Remove()
  end
 end
 Tag = Instance.new("ObjectValue")
 Tag.Parent = VictimHumanoid
 Tag.Name = "creator"
 Tag.Value = Attacker
end

And, I wish I could script something like this, but I also wish I could understand it, and I can't script something without knowing what it is.

1 answer

Log in to vote
3
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
9 years ago

This is actually from ROBLOX's built in tools originally.


There is a convention for marking who bloxxed who with a weapon. This convention exists because it is what the servers look at to keep track of KOs and WOs on your ROBLOX profile.

When someone dies, before their character gets cleaned up, an ObjectValue named creator is put into the dead character's Humanoid. The object value points to the person who did the killing of that character.


This method does all that-- it appropriately marks the VictimHumanoid as being killed by Attacker. It tags (as in marks) the dead with their killer which is why it's called CreateTag.

The way it does that is first deleting any children of the Humanoid that are named "creator" (lines 02 to 06).

It then creates a new ObjectValue (line 07) and names it "creator" (line 09), puts it in the dead humanoid (line 08) and says who did it by setting the value's Value to the attacker (line 10).

Ad

Answer this question