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

Nuke script that grows and kills people who touches?

Asked by 7 years ago
Edited by M39a9am3R 7 years ago

Please encode Lua code in the Lua block code tag (look for the Lua icon in the editor).
Instance.new("Part",workspace)

local nuke = game.Workspace.Part

position = nuke.CFrame

while wait(0.1) do
    nuke.Size = nuke.Size + Vector3.new(0.5,0.5,0.5)

    nuke.CFrame = position

end

function onTouch(Brick)

    local Player = Brick.Parent:FindFirstChild("Humanoid")

    if(Player ~= nil)then

        Player.Health = Player.Health - 100


    end

end


nuke.Touched:connect(onTouch)


0
Do not only post code into your question, add an explanation to it. What is the problem? Link150 1355 — 7y
0
Ok my bad, first time with this site and scripting and all. I'm trying to make a "nuke" (really a part that grows and if you touch it you die) The part grows and all but I can't figure out why it wont kill me when I touch it. AgentPotato425 0 — 7y

1 answer

Log in to vote
2
Answered by
BlackJPI 2658 Snack Break Moderation Voter Community Moderator
7 years ago

You are running an infinite loop before connecting the touched event, so the event never gets connected to the part.

Solution:

local nuke = Instance.new("Part", game.Workspace)

nuke.Touched:connect(function(hit)
    local humanoid = hit.Parent:FindFirstChild("Humanoid")
    if humanoid then
        humanoid.Health = 0
    end
end)

while wait() do
    nuke.Size = nuke.Size + Vector3.new(0.5, 0.5, 0.5)
    nuke.CFrame = CFrame.new()
end
0
Thanks man. AgentPotato425 0 — 7y
Ad

Answer this question