Guest User

Untitled

a guest
Apr 14th, 2025
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.79 KB | None | 0 0
  1. -- Ultimate HatHub Hand Script
  2. -- Fixed network issues
  3. -- Works for all players
  4. -- R8 & R15 compatible
  5.  
  6. local Players = game:GetService("Players")
  7. local LocalPlayer = Players.LocalPlayer
  8. local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
  9. local Humanoid = Character:WaitForChild("Humanoid")
  10. local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
  11.  
  12. -- Required hats configuration
  13. local HAT_CONFIGURATION = {
  14. Palm = "Nagamaki",
  15. Point1 = "Robloxclassicred",
  16. Point2 = "Pal Hair",
  17. Middle1 = "Pink Hair",
  18. Middle2 = "Hat1",
  19. Ring1 = "Kate Hair",
  20. Ring2 = "LavanderHair",
  21. Pinki1 = "Bedhead",
  22. Pinki2 = "BlockheadBaseballCap",
  23. Thumb = "MessyHair"
  24. }
  25.  
  26. -- Verify required hats
  27. local function verifyHats()
  28. for partName, hatName in pairs(HAT_CONFIGURATION) do
  29. if not Character:FindFirstChild(hatName) then
  30. warn("[HatHub] Missing hat: "..hatName.." ("..partName..")")
  31. return false
  32. end
  33. end
  34. return true
  35. end
  36.  
  37. if not verifyHats() then
  38. warn("[HatHub] Missing required hats - script disabled")
  39. return
  40. end
  41.  
  42. -- Physics optimization (client-side only)
  43. local function optimizePhysics()
  44. settings().Physics.AllowSleep = false
  45.  
  46. local function optimizeCharacterParts()
  47. for _, part in pairs(Character:GetDescendants()) do
  48. if part:IsA("BasePart") then
  49. part.CanCollide = false
  50. part.Massless = true
  51. part.CollisionGroup = "Player"
  52. part.AssemblyLinearVelocity = Vector3.new()
  53. part.AssemblyAngularVelocity = Vector3.new()
  54. end
  55. end
  56. end
  57.  
  58. -- Run optimization periodically
  59. local heartbeatConnection
  60. heartbeatConnection = game:GetService("RunService").Heartbeat:Connect(function()
  61. optimizeCharacterParts()
  62. end)
  63.  
  64. -- Initial optimization
  65. optimizeCharacterParts()
  66.  
  67. return heartbeatConnection
  68. end
  69.  
  70. local physicsConnection = optimizePhysics()
  71.  
  72. -- Hand parts initialization
  73. local HAND_PARTS = {
  74. Palm = Character[HAT_CONFIGURATION.Palm].Handle,
  75. Point1 = Character[HAT_CONFIGURATION.Point1].Handle,
  76. Point2 = Character[HAT_CONFIGURATION.Point2].Handle,
  77. Middle1 = Character[HAT_CONFIGURATION.Middle1].Handle,
  78. Middle2 = Character[HAT_CONFIGURATION.Middle2].Handle,
  79. Ring1 = Character[HAT_CONFIGURATION.Ring1].Handle,
  80. Ring2 = Character[HAT_CONFIGURATION.Ring2].Handle,
  81. Pinki1 = Character[HAT_CONFIGURATION.Pinki1].Handle,
  82. Pinki2 = Character[HAT_CONFIGURATION.Pinki2].Handle,
  83. Thumb = Character[HAT_CONFIGURATION.Thumb].Handle
  84. }
  85.  
  86. -- Cleanup existing constraints and meshes
  87. for _, part in pairs(HAND_PARTS) do
  88. for _, child in pairs(part:GetChildren()) do
  89. if child:IsA("SpecialMesh") or child:IsA("WeldConstraint") or child:IsA("Weld") then
  90. child:Destroy()
  91. end
  92. end
  93. -- Ensure each part has an attachment
  94. if not part:FindFirstChildOfClass("Attachment") then
  95. Instance.new("Attachment", part)
  96. end
  97. end
  98.  
  99. -- Create control attachments on HumanoidRootPart
  100. local CONTROL_ATTACHMENTS = {}
  101. for i = 1, 10 do
  102. local attachment = Instance.new("Attachment", HumanoidRootPart)
  103. attachment.Name = "HandControl_"..i
  104. table.insert(CONTROL_ATTACHMENTS, attachment)
  105. end
  106.  
  107. -- Alignment system (using Motor6D for better sync)
  108. local function createAlignment(part, controlAttachment)
  109. local motor = Instance.new("Motor6D")
  110. motor.Name = "HandAlignment"
  111. motor.Part0 = controlAttachment.Parent
  112. motor.Part1 = part
  113. motor.C0 = controlAttachment.CFrame
  114. motor.C1 = part.CFrame:inverse() * controlAttachment.CFrame
  115. motor.Parent = controlAttachment.Parent
  116.  
  117. -- Add velocity constraint for smoother movement
  118. local alignPos = Instance.new("AlignPosition", part)
  119. alignPos.Attachment0 = part:FindFirstChildOfClass("Attachment")
  120. alignPos.Attachment1 = controlAttachment
  121. alignPos.RigidityEnabled = false
  122. alignPos.ReactionForceEnabled = false
  123. alignPos.MaxForce = 50000
  124. alignPos.Responsiveness = 100
  125.  
  126. local alignOri = Instance.new("AlignOrientation", part)
  127. alignOri.Attachment0 = part:FindFirstChildOfClass("Attachment")
  128. alignOri.Attachment1 = controlAttachment
  129. alignOri.ReactionTorqueEnabled = false
  130. alignOri.MaxTorque = 50000
  131. alignOri.Responsiveness = 100
  132.  
  133. return {
  134. Motor = motor,
  135. AlignPosition = alignPos,
  136. AlignOrientation = alignOri
  137. }
  138. end
  139.  
  140. -- Create alignments for all hand parts
  141. local alignments = {
  142. Palm = createAlignment(HAND_PARTS.Palm, CONTROL_ATTACHMENTS[1]),
  143. Point1 = createAlignment(HAND_PARTS.Point1, CONTROL_ATTACHMENTS[2]),
  144. Point2 = createAlignment(HAND_PARTS.Point2, CONTROL_ATTACHMENTS[3]),
  145. Middle1 = createAlignment(HAND_PARTS.Middle1, CONTROL_ATTACHMENTS[4]),
  146. Middle2 = createAlignment(HAND_PARTS.Middle2, CONTROL_ATTACHMENTS[5]),
  147. Ring1 = createAlignment(HAND_PARTS.Ring1, CONTROL_ATTACHMENTS[6]),
  148. Ring2 = createAlignment(HAND_PARTS.Ring2, CONTROL_ATTACHMENTS[7]),
  149. Pinki1 = createAlignment(HAND_PARTS.Pinki1, CONTROL_ATTACHMENTS[8]),
  150. Pinki2 = createAlignment(HAND_PARTS.Pinki2, CONTROL_ATTACHMENTS[9]),
  151. Thumb = createAlignment(HAND_PARTS.Thumb, CONTROL_ATTACHMENTS[10])
  152. }
  153.  
  154. -- Default hand pose configuration
  155. local DEFAULT_POSE = {
  156. Positions = {
  157. CONTROL_ATTACHMENTS[1].Position = Vector3.new(0, 5, 5),
  158. CONTROL_ATTACHMENTS[2].Position = Vector3.new(-2, 6.2, 3.12),
  159. CONTROL_ATTACHMENTS[3].Position = Vector3.new(-2, 6.4, 1.4),
  160. CONTROL_ATTACHMENTS[4].Position = Vector3.new(-0.6, 6.2, 3.12),
  161. CONTROL_ATTACHMENTS[5].Position = Vector3.new(-0.6, 6.4, 1.4),
  162. CONTROL_ATTACHMENTS[6].Position = Vector3.new(0.7, 6.2, 3.12),
  163. CONTROL_ATTACHMENTS[7].Position = Vector3.new(0.7, 6.4, 1.4),
  164. CONTROL_ATTACHMENTS[8].Position = Vector3.new(2, 6.2, 3.12),
  165. CONTROL_ATTACHMENTS[9].Position = Vector3.new(2, 6.4, 1.4),
  166. CONTROL_ATTACHMENTS[10].Position = Vector3.new(3, 4.5, 4.7)
  167. },
  168. Rotations = {
  169. Palm = Vector3.new(50, 0, 0),
  170. Point1 = Vector3.new(-20, 0, 0),
  171. Point2 = Vector3.new(5, 0, 0),
  172. Middle1 = Vector3.new(-20, 0, 0),
  173. Middle2 = Vector3.new(5, 0, 0),
  174. Ring1 = Vector3.new(-20, 0, 0),
  175. Ring2 = Vector3.new(5, 0, 0),
  176. Pinki1 = Vector3.new(-20, 0, 0),
  177. Pinki2 = Vector3.new(5, 0, 0),
  178. Thumb = Vector3.new(0, 30, 0)
  179. }
  180. }
  181.  
  182. -- Pose system
  183. local currentPose = "default"
  184. local POSE_CONFIGURATIONS = {
  185. ["default"] = DEFAULT_POSE,
  186.  
  187. ["fist"] = {
  188. Positions = {
  189. CONTROL_ATTACHMENTS[1].Position = Vector3.new(0, 3.6, 0),
  190. CONTROL_ATTACHMENTS[2].Position = Vector3.new(-2, 4.6, -1),
  191. CONTROL_ATTACHMENTS[3].Position = Vector3.new(-2, 4.1, -2),
  192. CONTROL_ATTACHMENTS[4].Position = Vector3.new(-0.7, 4.6, -1),
  193. CONTROL_ATTACHMENTS[5].Position = Vector3.new(-0.7, 4.1, -2),
  194. CONTROL_ATTACHMENTS[6].Position = Vector3.new(0.7, 4.6, -1),
  195. CONTROL_ATTACHMENTS[7].Position = Vector3.new(0.7, 4.1, -2),
  196. CONTROL_ATTACHMENTS[8].Position = Vector3.new(2, 6, 0),
  197. CONTROL_ATTACHMENTS[9].Position = Vector3.new(-2, 5, -0.5),
  198. CONTROL_ATTACHMENTS[10].Position = Vector3.new(3.3, 2.6, 0)
  199. },
  200. Rotations = {
  201. Palm = Vector3.new(0, 0, 0),
  202. Point1 = Vector3.new(-180, 0, 0),
  203. Point2 = Vector3.new(-270, 0, 0),
  204. Middle1 = Vector3.new(-180, 0, 0),
  205. Middle2 = Vector3.new(-270, 0, 0),
  206. Ring1 = Vector3.new(-180, 0, 0),
  207. Ring2 = Vector3.new(-270, 0, 0),
  208. Pinki1 = Vector3.new(90, 0, 0),
  209. Pinki2 = Vector3.new(90, 0, 0),
  210. Thumb = Vector3.new(0, 90, 0)
  211. }
  212. }
  213. -- Add more poses here
  214. }
  215.  
  216. local function applyPose(poseName)
  217. if not POSE_CONFIGURATIONS[poseName] then return end
  218.  
  219. currentPose = poseName
  220. local pose = POSE_CONFIGURATIONS[poseName]
  221.  
  222. -- Apply positions
  223. for attachment, position in pairs(pose.Positions) do
  224. attachment.Position = position
  225. end
  226.  
  227. -- Apply rotations
  228. for partName, rotation in pairs(pose.Rotations) do
  229. HAND_PARTS[partName]:FindFirstChildOfClass("Attachment").Rotation = rotation
  230. end
  231. end
  232.  
  233. -- Input handling
  234. local UserInputService = game:GetService("UserInputService")
  235. local inputConnections = {}
  236.  
  237. local function setupInput()
  238. -- Clear existing connections
  239. for _, conn in pairs(inputConnections) do
  240. conn:Disconnect()
  241. end
  242.  
  243. -- New connections
  244. inputConnections["Q"] = UserInputService.InputBegan:Connect(function(input, gameProcessed)
  245. if gameProcessed then return end
  246. if input.KeyCode == Enum.KeyCode.Q then
  247. applyPose("default")
  248. end
  249. end)
  250.  
  251. inputConnections["E"] = UserInputService.InputBegan:Connect(function(input, gameProcessed)
  252. if gameProcessed then return end
  253. if input.KeyCode == Enum.KeyCode.E then
  254. applyPose("fist")
  255. end
  256. end)
  257. end
  258.  
  259. setupInput()
  260.  
  261. -- UI
  262. local ScreenGui = Instance.new("ScreenGui")
  263. ScreenGui.Name = "HatHubUI"
  264. ScreenGui.Parent = game.CoreGui
  265. ScreenGui.ResetOnSpawn = false
  266.  
  267. local Frame = Instance.new("Frame")
  268. Frame.Parent = ScreenGui
  269. Frame.Size = UDim2.new(0, 200, 0, 50)
  270. Frame.Position = UDim2.new(0.5, -100, 1, -100)
  271. Frame.BackgroundTransparency = 0.7
  272. Frame.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
  273.  
  274. local TextLabel = Instance.new("TextLabel")
  275. TextLabel.Parent = Frame
  276. TextLabel.Size = UDim2.new(1, 0, 1, 0)
  277. TextLabel.Text = "HatHub Hand - Pose: "..currentPose
  278. TextLabel.BackgroundTransparency = 1
  279. TextLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
  280. TextLabel.Font = Enum.Font.SourceSansBold
  281. TextLabel.TextSize = 18
  282.  
  283. -- Update UI
  284. game:GetService("RunService").Heartbeat:Connect(function()
  285. TextLabel.Text = string.format("HatHub Hand\nPose: %s", currentPose)
  286. end)
  287.  
  288. -- Initial pose
  289. applyPose("default")
  290.  
  291. -- Cleanup on character reset
  292. local function onCharacterAdded(newCharacter)
  293. Character = newCharacter
  294. Humanoid = Character:WaitForChild("Humanoid")
  295. HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
  296.  
  297. -- Reinitialize everything
  298. if physicsConnection then
  299. physicsConnection:Disconnect()
  300. end
  301. physicsConnection = optimizePhysics()
  302.  
  303. -- Recreate UI if needed
  304. if not ScreenGui or not ScreenGui.Parent then
  305. ScreenGui = Instance.new("ScreenGui")
  306. ScreenGui.Name = "HatHubUI"
  307. ScreenGui.Parent = game.CoreGui
  308. end
  309.  
  310. applyPose(currentPose)
  311. end
  312.  
  313. LocalPlayer.CharacterAdded:Connect(onCharacterAdded)
  314.  
  315. print("[HatHub] Hand script loaded successfully!")
Advertisement
Add Comment
Please, Sign In to add comment