Advertisement
DrawingJhon

Original Button Script

Jun 19th, 2020
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.89 KB | None | 0 0
  1.     local model = Instance.new("Model", workspace)
  2. model.Name = "Button"
  3. local p = Instance.new("Part", model)
  4. p.Anchored = true
  5. p.TopSurface = Enum.SurfaceType.Smooth
  6. p.BottomSurface = Enum.SurfaceType.Smooth
  7. p.Position = Vector3.new(3.65, 1.6, 14.35)
  8. p.Size = Vector3.new(0.9, 3.2, 0.9)
  9. p.BrickColor = BrickColor.new("Ghost grey")
  10. local p2 = Instance.new("Part", model)
  11. p2.Anchored = true
  12. p2.TopSurface = Enum.SurfaceType.Smooth
  13. p2.BottomSurface = Enum.SurfaceType.Smooth
  14. p2.Position = Vector3.new(3.57, 3.175, 14.35)
  15. p2.Size = Vector3.new(1.5, 0.5, 1.5)
  16. p2.Rotation = Vector3.new(0, 0, 30)
  17. p2.BrickColor = BrickColor.new("Ghost grey")
  18. local boton = Instance.new("Part", model)
  19. boton.Anchored = true
  20. boton.TopSurface = Enum.SurfaceType.Smooth
  21. boton.BottomSurface = Enum.SurfaceType.Smooth
  22. boton.Position = Vector3.new(3.37, 3.521, 14.35)
  23. boton.Size = Vector3.new(1.1, 0.3, 1.1)
  24. boton.Rotation = Vector3.new(0, 0, 30)
  25. boton.BrickColor = BrickColor.new("Cyan")
  26. boton.Name = "supButton"
  27. local clickDetector = Instance.new("ClickDetector")
  28. clickDetector.Parent = boton
  29. local function localPos(changePart, x, y, z)
  30.     local new_cframe = changePart.CFrame * CFrame.new(Vector3.new(x, y, z))
  31.     changePart.CFrame = new_cframe
  32. end
  33. local touched = false
  34.  
  35. clickDetector.MouseClick:Connect(function(plr)
  36.     if touched == false then
  37.         local num = math.random(1,3)
  38.         touched = true
  39.         print(plr.Name.." touched the button")
  40.         localPos(boton, 0, -0.2, 0)
  41.         clickDetector.MaxActivationDistance = 0
  42.         if plr.Character and num == 1 then
  43.             if plr.Character:findFirstChild("HumanoidRootPart") ~= nil then
  44.                 local explo = Instance.new("Explosion",workspace)
  45.                 explo.Position = plr.Character:findFirstChild("HumanoidRootPart").Position
  46.             end
  47.         end
  48.         if num == 2 then
  49.             if plr.Character then
  50.                 for i, v in pairs(plr.Character:GetChildren()) do
  51.                     if v.ClassName == "Accessory" then
  52.                         v:Destroy()
  53.                     end
  54.                 end
  55.             end
  56.         end
  57.         if num == 3 then
  58.             if plr.Character then
  59.                 for i, v in pairs(plr.Character:GetChildren()) do
  60.                     if v.ClassName == "Shirt" or v.ClassName == "Pants" then
  61.                         v:Destroy()
  62.                     end
  63.                 end
  64.             end
  65.         end
  66.         wait(3)
  67.         localPos(boton, 0, 0.2, 0)
  68.         clickDetector.MaxActivationDistance = 32
  69.         touched = false
  70.     end
  71. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement