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

Help Me With My Humanoids Please?

I Need Some One To Help Me, I'm Making A Zombie Game And Every Time One Of The Zombies Die I Want Them To Regen, I'm New To Coding So I Don't Know Every Thing But I Have This So Far:

local regenTime = 60 
local messageTime = 2.5

local model = script.Parent
local message = Instance.new("Message")

if model ~= workspace then 

	local backup = model:clone() 

	while true do 
		wait(60) 

		message.Parent = game.Workspace 
		wait(messageTime)
		message.Parent = nil

		--Copy the backup
		model = backup:clone() 
		model.Parent = game.Workspace 
		model:makeJoints()
	end
else
	error("Script not put in a model! Nothing to regenerate!")
end 

Can Some One Edit This So It Only Regens Upon Death Of The Humanoid?

3 comments

0

Use the Died event. Look it up in the wiki

0

Thanks For That Tip, But How Do I Make It Do The Clone With The Example It Gives?

0

mario i already answered your question

1 answer

here's my edited script.

local Save = script.Parent:Clone()
Save.Parent = game.ServerStorage

local regenTime = 60
local messageTime = 2.5

local model = script.Parent
local message = Instance.new("Message")

function IsDead() -- checks if character is dead or not
	if model.Humanoid.Health <= 0 then
		return true
		else return false
	end
end

while true do
	if IsDead() then
		message.Parent = game.Workspace
		message.Text = "Regening..."
		wait(messageTime)
		message.Parent = nil - messaging
		wait(regenTime)
		-- respawn the dead character
		local GetBackup = Save:Clone()
		GetBackup.Parent = game.Workspace
		break -- braking the loop
	end
	wait()
end
model.Parent = nil -- cleaning the died zombie

After the new character spawns, the died one will be cleaned. Make sure its under the character

1 comment

0

Thank You dav1000999, This Worked!

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