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

Can someone help me with Regen Button?

Hello, i have problem with regen button, need add wait(), but idk where. It regen too fast.

model = script.Parent.Parent
messageText = ""

message = Instance.new("Message")
message.Text = messageText
backup = model:clone()
enabled = true

function regenerate()
	message.Parent = game.Workspace
	model:remove()

	wait(0)

	model = backup:clone()
	model.Parent = game.Workspace
	model:makeJoints()
	message.Parent = nil

	script.Disabled = true
	script.Parent.BrickColor = BrickColor.new(26)--Black
	wait(150)-- here is something, but don't work.
	script.Parent.BrickColor = BrickColor.new(104)--Purple
	script.Disabled = false
end

function onTouched()	
	if enabled then
		regenerate()
	end
end

 script.Parent.Touched:connect(onTouched)

1 answer

✓ Accepted answer
model = script.Parent.Parent
messageText = ""

message = Instance.new("Message")
message.Text = messageText
backup = model:clone()
enabled = true

function regenerate()
    message.Parent = game.Workspace
    model:remove()

    wait(2) --Change this to two

    model = backup:clone()
    model.Parent = game.Workspace
    model:makeJoints()
    message.Parent = nil

    script.Disabled = true
    script.Parent.BrickColor = BrickColor.new(26)--Black
    wait(150)--This is how long until it is regenable again
    script.Parent.BrickColor = BrickColor.new(104)--Purple
    script.Disabled = false
end

function onTouched()    
    if enabled then
	enabled = false
        regenerate()
	enabled = true --Added a debounce for ya.
    end
end

 script.Parent.Touched:connect(onTouched)

1 comment

0

Thanks. Now i understand how it work.

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