The Roblox sword has this neat script that, upon making contact with another humanoid, creates an object value in the humanoid with the value being the creator. This is a very efficient way to give cash or experience points to the attacker after killing another player. Is there any way to do this same thing with a raycast gun?
✓ ANSWER ACCEPTED
Is it possible to tag humanoids with a gun?
1 answer
✓ Accepted answer
Yes, Leedle it is possible!
To do this it's fairly simple! In the below script I will demonstrate a slightly different example but it should give you a grasp of how to do this!
local Part = script.Parent
local function partTouched(hit)
if (hit.Parent:FindFirstChild('Humanoid') then --Check if whatever hit it has a humanoid
local PlayersChar = hit.Parent --Defining PlayersChar
local creatorVal = Instance.new('ObjectValue') --Creating an ObjectValue
creatorVal.Name = 'Creator' --Setting the name of the new objectvalue
creatorVal.Value = Part --setting the part as the ObjectValues value
creatorVal.Parent = PlayersChar:WaitForChild('Humanoid') -- Lastly, setting the new ObjectValues parent to the PlayersChar humanoid
end
end
Part.Touched:Connect(partTouched)
Keep in mind the above script is untested and was typed out from mere experience
Happy scripting!
This discussion is preserved as it was. New answers, comments, and votes are closed.

4 comments
Then from another script you could get the ObjectValue from the damaged player, then proceed to change anything you'd like from the creator value!
This works good but is it possible for the Value to be the player (not the physical character) who is attacking? This makes it so that the bullet is the value.
I'm not sure about that; however, what I'd do is simple! I'd make an IntValue and just set the Value to the Players name. Then in another script, just take the Players name, find it in game.Players then get that Players object if that makes sense.
Gotcha, thanks for your time.