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

Anyone know how to make this regen script turn black for 150 seconds?

I have a regen button. It works fine :) But I want the button to turn black to mark how long until it shows when it can regen. here is the code.

local model = game.Workspace.Giant
local message = Instance.new("Message")
      message.Text = "Regenerating "..model.Name
local backup = model:clone()
local regenerating = false

function regenerate()
	--Don't regenerate again if we're already doing it!
	if regenerating then
		return
	else
		regenerating = true
	end

	model:Destroy()

	-- Display the regen message for 4 seconds
	message.Parent = game.Workspace
	wait(4)
	message.Parent = nil 
	
	-- Put the copied model back into workspace
	model = backup:clone()
	model.Parent = game.Workspace
	model:makeJoints()

	-- After 30 seconds, allow the model to be regenerated again
	wait(150)
	regenerating = false
end

--Connect a function that regenerates the model when a player touches the button NEED UR HELP!
script.Parent.Touched:connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		regenerate()
	end
end)

Help respected

1 answer

✓ Accepted answer
local model = game.Workspace.Giant
local message = Instance.new("Message")
      message.Text = "Regenerating "..model.Name
local backup = model:clone()
local regenerating = false

function regenerate()
    --Don't regenerate again if we're already doing it!
    if regenerating then
        return
    end

    regenerating = true
    script.Parent.BrickColor = BrickColor.new("Black")

    model:Destroy()

    -- Display the regen message for 4 seconds
    message.Parent = game.Workspace
    wait(4)
    message.Parent = nil 

    -- Put the copied model back into workspace
    model = backup:clone()
    model.Parent = game.Workspace
    model:makeJoints()

    -- After 30 seconds, allow the model to be regenerated again
    wait(150)
    regenerating = false
    script.Parent.BrickColor = BrickColor.new("Bright purple")
end

--Connect a function that regenerates the model when a player touches the button NEED UR HELP!
script.Parent.Touched:connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        regenerate()
    end
end)

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