Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Can someone help me with Regen Button?

Asked by 9 years ago

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

Log in to vote
0
Answered by 9 years ago
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)

0
Thanks. Now i understand how it work. karolus1 8 — 9y
Ad

Answer this question