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

How do I Create A Regeneration Script for a Model?

Asked by
SirPaco 66
8 years ago

How do I create a Regeneration Script for a Model? I would this function to execute after a Button with a ClickDetector has been Clicked.

Humanoid Regeneration Script:

local NPC = script.Parent
local NPC2 = NPC:Clone()

NPC.Humanoid.Died:connect(function()
    script.Parent = workspace
    wait(5)
    NPC:Destroy()
    wait(10)
    NPC2:Clone().Parent =  game.Workspace
    script:Destroy()
end)
0
create a while loop that adds 1 on to the npc's humanoid's health until it's health is it's maxhealth TheDeadlyPanther 2460 — 8y

1 answer

Log in to vote
0
Answered by
FiredDusk 1466 Moderation Voter
8 years ago
local NPC = script.Parent
local NPC2 = NPC:Clone()

NPC.Humanoid.Died:connect(function()
    NPC.Parent = game.Workspace --The problem is here. You made a variable called "NPC" which mean "script.Parent" so then you would need to make the "script.Parent" you have on this line of code to be "NPC" then add ".Parent" to parent it to workspace.
    wait(5)
    NPC:Destroy()
    wait(10)
    NPC2:Clone().Parent =  game.Workspace --Good job over here.
    script:Destroy()
end)
Ad

Answer this question