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

How would I make it so after a brick is touched the model regens?

i have this already but i cant get it to regenerate after its removed

function onTouched(hit)
	local e = Instance.new("Explosion")
	e.BlastRadius = 300
	e.BlastPressure = 5000
	e.Parent = game.Workspace
	e.Position = script.Parent.Position
	wait(1)
	local Hint = Instance.new('Hint', Workspace)
	Hint.Text = "playername got pwnd"
	wait(2)
	Hint:Destroy()
	wait(.1)
	game.Workspace.bk:remove()

end
script.Parent.Touched:connect(onTouched)

3 answers

Instead of calling :remove() on the object you want to get rid of, set a variable to it and set it's parent to nil. When you want to bring it back, use the variable to set it's parent back to Workspace.

If the object gets destroyed in the explosion, you'll instead want to make a clone of the object and store it in ServerStorage. When you want to bring the object back, clone the object from ServerStorage and set it's parent to Workspace.

1 comment

0

That's kind of what I did. He also made other mistakes in the script, so I did it for him.

You made a few errors and left out some vital stuff. For the touched event, you have to check if it's a player. Or else, a random brick could hit it and it would explode.

script.Parent.Touched:connect(function(hit)
	if hit.Parent and game.Players:GetPlayerFromCharacter(hit.Parent) then
		p = game.Players:GetPlayerFromCharacter(hit.Parent)
		aa = script.Parent:clone()
		aa.Parent = game.Lighting
		aa.Name = "Clone"
		local e = Instance.new("Explosion")
		e.BlastRadius = 300
		e.BlastPressure = 5000
		e.Parent = script.Parent
		e.Position = script.Parent.Position
		wait(1)
		local Hint = Instance.new('Hint', Workspace)
		Hint.Text = p.Name.." got pwnd"
		wait(2)
		Hint:Destroy()
		wait(.1)
		aa.Parent = Workspace
		--game.Workspace.bk:remove()
		--I'm not sure if the above is necessary. If it is, just remove the '--'
	end
end)

-- Made by BuildingAustin

model = game.Workspace.Brick -- First you change "coolironman"coolironman" (It can't have spaces) backup = model:clone()

function onChatted(msg, recipient, speaker)

local source = string.lower(speaker.Name) msg = string.lower(msg)

if (msg == "titanic") then -- change "Iron man regen" to what ever you want to say to regenerate a model. model:remove() model = backup:clone() model.Parent = game.Workspace model:makeJoints() end

end

function onPlayerEntered(newPlayer) newPlayer.Chatted:connect(function(msg, recipient) onChatted(msg, recipient, newPlayer) end) end

game.Players.ChildAdded:connect(onPlayerEntered)

Try this it works better!

3 comments

0

This is no where close to what he wanted...

0

Its a Voice thing

0

He wanted it where when it explodes, it auto-regenerates.

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