Advertisement
ERROR_CODE

Hug Gui

Sep 1st, 2024 (edited)
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.66 KB | None | 0 0
  1. if game.Players.LocalPlayer.Character.Humanoid.RigType == Enum.HumanoidRigType.R6 then
  2. if game:GetService("CoreGui"):FindFirstChild("HUGUI") then
  3. game:GetService("CoreGui"):FindFirstChild("HUGUI"):Destroy()
  4. end
  5. HUGUI = Instance.new("ScreenGui")
  6. HFrame = Instance.new("Frame")
  7. HTopBar = Instance.new("Frame")
  8. CloseButton = Instance.new("TextButton")
  9. HugButton = Instance.new("TextButton")
  10. HugLabel = Instance.new("TextLabel")
  11. UserInputService = game:GetService("UserInputService")
  12. MinTab = Instance.new("TextButton")
  13.  
  14. HUGUI.Name = "HUGUI"
  15. HUGUI.Parent = game.CoreGui
  16. HUGUI.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
  17. game.CoreGui.HUGUI.Enabled = true
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26. HTopBar.Name = "HTopBar"
  27. HTopBar.Parent = HUGUI
  28. HTopBar.AnchorPoint = Vector2.new(0.5, 0.5)
  29. HTopBar.Position = UDim2.new(0.5, 0, 0.5, 0)
  30. HTopBar.Size = UDim2.new(0, 250, 0, 50)
  31. HTopBar.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
  32. HTopBar.ZIndex = 2
  33.  
  34. CloseButton.Name = "CloseButton"
  35. CloseButton.Parent = HTopBar
  36. CloseButton.AnchorPoint = Vector2.new(0.5, 0.5)
  37. CloseButton.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
  38. CloseButton.Position = UDim2.new(0.845, 0, 0.5, 0)
  39. CloseButton.Size = UDim2.new(0, 80, 0, 50)
  40. CloseButton.Font = Enum.Font.SourceSans
  41. CloseButton.TextSize = 35
  42. CloseButton.TextColor3 = Color3.fromRGB(255, 255, 255)
  43. CloseButton.Text = "X"
  44.  
  45. CloseButton.MouseButton1Click:Connect(function()
  46. HUGUI:Destroy()
  47. end)
  48.  
  49. MinTab.Name = "MinTab"
  50. MinTab.Parent = HTopBar
  51. MinTab.AnchorPoint = Vector2.new(0.5, 0.5)
  52. MinTab.BackgroundColor3 = Color3.fromRGB(0, 0, 255)
  53. MinTab.Position = UDim2.new(0.54, 0, 0.5, 0)
  54. MinTab.Size = UDim2.new(0, 80, 0, 50)
  55. MinTab.Font = Enum.Font.SourceSans
  56. MinTab.TextSize = 50
  57. MinTab.TextColor3 = Color3.fromRGB(255, 255, 255)
  58. MinTab.Text = "-"
  59.  
  60. MinTab.MouseButton1Click:Connect(function()
  61. if MinTab.Text == "-" then
  62. MinTab.Text = "+"
  63. HFrame.Visible = false
  64. else
  65. if MinTab.Text == "+" then
  66. MinTab.Text = "-"
  67. HFrame.Visible = true
  68. end
  69. end
  70. end)
  71.  
  72. HFrame.Name = "HFrame"
  73. HFrame.Parent = HTopBar
  74. HFrame.AnchorPoint = Vector2.new(0.5, 0.5)
  75. HFrame.Position = UDim2.new(0.5, 0, 2.5, 0)
  76. HFrame.Size = UDim2.new(0, 250, 0, 150)
  77. HFrame.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
  78.  
  79. HugButton.Name = "HugButton"
  80. HugButton.Parent = HFrame
  81. HugButton.AnchorPoint = Vector2.new(0.5, 0.5)
  82. HugButton.BackgroundColor3 = Color3.fromRGB(80, 80, 80)
  83. HugButton.Position = UDim2.new(0.5, 0, 0.7, 0)
  84. HugButton.Size = UDim2.new(0, 180, 0, 80)
  85. HugButton.Font = Enum.Font.SourceSans
  86. HugButton.TextSize = 50
  87. HugButton.TextColor3 = Color3.fromRGB(255, 255, 255)
  88. HugButton.Text = "HUG\nOff"
  89.  
  90. HugButton.MouseButton1Click:Connect(function()
  91. if HugButton.Text == "HUG\nOff" then
  92. HugButton.Text = "HUG\nOn"
  93. Anim_1 = Instance.new("Animation")
  94. Anim_1.AnimationId = "rbxassetid://283545583"
  95. Play_1 = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(Anim_1)
  96. Anim_2 = Instance.new("Animation")
  97. Anim_2.AnimationId = "rbxassetid://225975820"
  98. Play_2 = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(Anim_2)
  99. Play_1:Play()
  100. Play_2:Play()
  101. else
  102. if HugButton.Text == "HUG\nOn" then
  103. HugButton.Text = "HUG\nOff"
  104. Play_1:Stop()
  105. Play_2:Stop()
  106. end
  107. end
  108. end)
  109.  
  110. HugLabel.Name = "HugLabel"
  111. HugLabel.Parent = HFrame
  112. HugLabel.AnchorPoint = Vector2.new(0.5, 0.5)
  113. HugLabel.BackgroundTransparency = 1
  114. HugLabel.Position = UDim2.new(0.5, 0, 0.15, 0)
  115. HugLabel.Size = UDim2.new(0, 180, 0, 80)
  116. HugLabel.Font = Enum.Font.SourceSans
  117. HugLabel.TextSize = 28
  118. HugLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
  119. HugLabel.Text = "Go up to the man and hug him >_<"
  120. HugLabel.TextWrapped = true
  121.  
  122. local gui = HTopBar
  123.  
  124. local dragging
  125. local dragInput
  126. local dragStart
  127. local startPos
  128.  
  129. local function update(input)
  130.     local delta = input.Position - dragStart
  131.     gui.Position = UDim2.new(startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y)
  132. end
  133.  
  134. gui.InputBegan:Connect(function(input)
  135.     if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
  136.         dragging = true
  137.         dragStart = input.Position
  138.         startPos = gui.Position
  139.  
  140.         input.Changed:Connect(function()
  141.             if input.UserInputState == Enum.UserInputState.End then
  142.                 dragging = false
  143.             end
  144.         end)
  145.     end
  146. end)
  147.  
  148. gui.InputChanged:Connect(function(input)
  149.     if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch then
  150.         dragInput = input
  151.     end
  152. end)
  153.  
  154. UserInputService.InputChanged:Connect(function(input)
  155.     if input == dragInput and dragging then
  156.         update(input)
  157.     end
  158. end)
  159.  
  160. else
  161. warn("Need R6")
  162. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement