KidSurgeonGaming

Roblox Studio Regen Button

Feb 20th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. local model = game.Workspace.MyModelName
  2.  
  3. local message = Instance.new("Message")
  4. message.Text = "Regenerating "..model.Name
  5. local backup = model:clone()
  6. local regenerating = false
  7.  
  8. function regenerate()
  9. --Don't regenerate again if we're already doing it!
  10. if regenerating then
  11. return
  12. else
  13. regenerating = true
  14. end
  15.  
  16. model:Destroy()
  17.  
  18. -- Display the regen message for 4 seconds
  19. message.Parent = game.Workspace
  20. wait(4)
  21. message.Parent = nil
  22.  
  23. -- Put the copied model back into workspace
  24. model = backup:clone()
  25. model.Parent = game.Workspace
  26. model:makeJoints()
  27.  
  28. -- After 30 seconds, allow the model to be regenerated again
  29. wait(30)
  30. regenerating = false
  31. end
  32.  
  33. --Connect a function that regenerates the model when a player touches the button
  34. script.Parent.Touched:connect(function(hit)
  35. if hit.Parent:FindFirstChild("Humanoid") then
  36. regenerate()
  37. end
  38. end)
Add Comment
Please, Sign In to add comment