RobBobDev

UI Tweening And Clicking Detections With Functions

Apr 7th, 2022
1,356
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.37 KB | None | 0 0
  1. local UI = script.Parent
  2.  
  3. local P = UI.Prisoner
  4. local C = UI.Cop
  5. local N = UI.Neutral
  6.  
  7. local pReset = UDim2.new(0.8, 0,0.5, 0)
  8. local cReset = UDim2.new(0.5, 0,0.5, 0)
  9. local nReset = UDim2.new(0.2, 0,0.5, 0)
  10.  
  11. local PC = P.PrisonerConfirm
  12. local CC = C.CopConfirm
  13. local NC = N.NeutralConfirm
  14.  
  15. local plr = game.Players
  16.    
  17.     P.Text = "Prisoner"
  18.     C.Text = "Cop"
  19.     N.Text = "Neutral" 
  20.  
  21.  
  22. local function copClick()
  23.    
  24.     CC.Visible = true
  25.     CC.Text = "Confirm"
  26.    
  27.     N:TweenPosition(
  28.         UDim2.new(-0.1, 0,0.5, 0),
  29.         Enum.EasingDirection.In,
  30.         Enum.EasingStyle.Sine,
  31.         2,
  32.         true
  33.        
  34.        
  35.     )
  36.    
  37.     P:TweenPosition(
  38.         UDim2.new(1.1, 0,0.5, 0),
  39.         Enum.EasingDirection.In,
  40.         Enum.EasingStyle.Sine,
  41.         2,
  42.         true
  43.  
  44.  
  45.     )
  46.    
  47.     CC.MouseButton1Click:Connect(function()
  48.        
  49.         C:TweenPosition(
  50.             UDim2.new(0.5, 0,-0.5, 0),
  51.             Enum.EasingDirection.In,
  52.             Enum.EasingStyle.Sine,
  53.             2,
  54.             true
  55.  
  56.  
  57.         )
  58.        
  59.     end)
  60.    
  61. end
  62.  
  63. local function prisonerClick()
  64.    
  65.     PC.Visible = true
  66.     PC.Text = "Confirm"
  67.    
  68.     N:TweenPosition(
  69.         UDim2.new(-0.1, 0,0.5, 0),
  70.         Enum.EasingDirection.In,
  71.         Enum.EasingStyle.Sine,
  72.         2,
  73.         true
  74.  
  75.  
  76.     )
  77.  
  78.     C:TweenPosition(
  79.         UDim2.new(-0.1, 0,0.5, 0),
  80.         Enum.EasingDirection.In,
  81.         Enum.EasingStyle.Sine,
  82.         2,
  83.         true
  84.  
  85.  
  86.     )
  87.  
  88.     PC.MouseButton1Click:Connect(function()
  89.  
  90.         P:TweenPosition(
  91.             UDim2.new(0.8, 0,-0.5, 0),
  92.             Enum.EasingDirection.In,
  93.             Enum.EasingStyle.Sine,
  94.             2,
  95.             true
  96.  
  97.  
  98.         )
  99.        
  100. end)
  101.         end
  102.  
  103. local function neutralClick()
  104.    
  105.     NC.Visible = true
  106.     NC.Text = "Confirm"
  107.    
  108.     P:TweenPosition(
  109.         UDim2.new(1.1, 0,0.5, 0),
  110.         Enum.EasingDirection.In,
  111.         Enum.EasingStyle.Sine,
  112.         2,
  113.         true
  114.  
  115.  
  116.     )
  117.  
  118.     C:TweenPosition(
  119.         UDim2.new(1.1, 0,0.5, 0),
  120.         Enum.EasingDirection.In,
  121.         Enum.EasingStyle.Sine,
  122.         2,
  123.         true
  124.  
  125.  
  126.     )
  127.     NC.MouseButton1Click:Connect(function()
  128.  
  129.         N:TweenPosition(
  130.             UDim2.new(-0.3, 0,-0.5, 0),
  131.             Enum.EasingDirection.In,
  132.             Enum.EasingStyle.Sine,
  133.             2,
  134.             true
  135.  
  136.  
  137.         )
  138.     end)
  139.         end
  140.  
  141. local function onPlayerClick()
  142.    
  143.     C.MouseButton1Click:Connect(copClick)
  144.     P.MouseButton1Click:Connect(prisonerClick)
  145.     N.MouseButton1Click:Connect(neutralClick)
  146.    
  147. end
  148.  
  149. local function resetAllUI()
  150.    
  151.     C.Position = cReset
  152.     P.Position = pReset
  153.     N.Position = nReset
  154.    
  155.     CC.Visible = false
  156.     PC.Visible = false
  157.     NC.Visible = false
  158.    
  159. end
  160.  
  161. UI.Reset.MouseButton1Click:Connect(resetAllUI)
  162.  
  163. while task.wait() do
  164.     onPlayerClick()
  165. end
Advertisement
Add Comment
Please, Sign In to add comment