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

(Scripting Student) How would I make a nuclear bomb script work? (NOT SOLVED)

Asked by 9 years ago

Hi! Thanks for viewing! I've currently taken to Lua scripting, and i'm following a scripting guide, See here http://www.roblox.com/Forum/ShowPost.aspx?PostID=37553216 I'm currently on the second step. I know how to call the function, but how would I make it get all the players in a certain radius? after that I'm pretty sure I could make it kill everyone. Thanks for any and all help!

0
Increase the blast Radius SamthekidRSsl 58 — 7y

2 answers

Log in to vote
0
Answered by
Maliux 0
9 years ago

There are others way but you could create a large invisible block that if onTouched would kill them.

0
The tutorial says I have to make it spread and use :BreakJoints, and I would feel as if I were cheating doing that. Thank you though. nightmare13542 45 — 9y
0
If you needed to do that. You could use a wait and a line that re-sizes such as wait(2) Part.Size = ("5, 5, 5") Maliux 0 — 9y
Ad
Log in to vote
0
Answered by
KarlXYZ 120
9 years ago
local originPart = game.Workspace.Part
local radius = 100

function killFromOrigin()
    for i,v in pairs (game.Workspace:GetChildren()) do
        local humanoid = v:FindFirstChild("Humanoid")
        local head = v:FindFirstChild("Head")
        if head ~= nil and humanoid ~= nil then
            if (originPart.Position - head.Position).Magnitude <= radius then
                humanoid.Health = 0
            end
        end
    end
end

originPart is the origin of the bomb, in the form of a part. radius is the radius length in studs.

Line 8 checks if the model in the Workspace is a player.

Line 9 uses Magnitude to check the distance between the originPart and the Head of the player to see if it is less than or equal to the value of the radius variable.

Line 10 kills the player.

Answer this question