Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I Create A Regeneration Script for a Model?

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)

1 comment

0

create a while loop that adds 1 on to the npc's humanoid's health until it's health is it's maxhealth

1 answer

✓ Accepted answer
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)

This discussion is preserved as it was. New answers, comments, and votes are closed.