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

how to make a new instance damage player and/or have a script in it?

Asked by
pwgth 11
3 years ago

well, you see, when you make a new instance, it's just a plain old brick or whatever you made the new instance of. which led me to the question, how could I make it so that the instance damages people/have its own script? like always, I wish to learn.

1 answer

Log in to vote
0
Answered by 3 years ago

Is this what you're looking for?

local brick = Instance.new("Part")

brick.Parent = workspace

brick.Touched:Connect(function(toucher)
    local human = toucher.Parent:FindFirstChild("Humanoid")
    local damage = 42

    if human then
        human:TakeDamage(damage)
    end
end
0
thanks. pwgth 11 — 3y
Ad

Answer this question