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

How does humanoid tagging work? (Credit for kill)

Asked by
robi81 0
8 years ago

So I have a script that instantiates a part and flings it in whatever direction the gun is facing. It's a projectile basically. After this projectile is created and sent to fly off to the target a new script is then copied into the projectile. That script is the one I'm having trouble with. So there are two script at work here. The first one creates a block, shoots it forward, and then inserts a second script into that projectile block. This second script is what kills through the use of a ray, however the player that is killed is not tagged, therefore not rewarding any kills or points. So that is what I need help with. Here is the killer brick ray script, it kills but doesn't tag:

--*Ray creation*
local ray = Ray.new(script.Parent.Position,(script.Parent.CFrame.lookVector).unit * 500) 
local hit, position = game.Workspace:FindPartOnRay(ray, user)
local humanoid = hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid")

if humanoid then --*The damaging*
    wait(0.5) 
    print("Got that goon good!")
    humanoid:TakeDamage(100) 
end

Ultimately this is going to be a plane gun and in the first script the projectile is instantiated by pressing the F key. I've gotten this far and the pesky tagging is all I have left to do, but I can't figure it out. I looked at weapon scripts to see how they do it but they didn't seem like they would work in this case, or maybe I just couldn't make sense of it. I'm not asking for the rest of the script to be written for me, I just need help figuring out how this tagging business works. Where in this script would the lines related to tagging go? Can someone provide maybe a breakdown of how it works? That would really help, I do want to understand it. The wiki didn't really help, because the page about this subject used a sword script or something as an example, and didn't really break it down. Just to make something clear, this script is NOT a tool script like for a gun or sword, which is why I think I can't really find help on this but idk. The first script is the plane tool script, this one just adds a killer ray to a brick. What I'm really asking for is a breakdown of what every line does, and tips on how it can be applied in this script to help me start it off.

Answer this question