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

How to make a bullet?

Asked by 10 years ago
function onTouched()
    if game.Workspace.BaseShot
end

script.Parent.Touched:connect(onTouched)

How can I make this is that if someone gets hit by BaseShot they get killed?

1 answer

Log in to vote
0
Answered by 10 years ago

You should have the script inside every bullet, or else when multiple bullets spawn, it will be messier to deal with all of them and the code would more more difficult. Anyway, put this inside a bullet:

function touch(part)
    if part then
        local human = part.Parent:FindFirstChild("Humanoid") or script.Parent.Parent:FindFirstChild("Humanoid") -- This looks bit strange, so you could shoot hats too
        if human then
            human.Health = 0
        end
        script.Parent:Destroy()
    end
end

script.Parent.Touched:connect(touch)
Ad

Answer this question