Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Ultimate HatHub Hand Script
- -- Fixed network issues
- -- Works for all players
- -- R8 & R15 compatible
- local Players = game:GetService("Players")
- local LocalPlayer = Players.LocalPlayer
- local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
- local Humanoid = Character:WaitForChild("Humanoid")
- local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
- -- Required hats configuration
- local HAT_CONFIGURATION = {
- Palm = "Nagamaki",
- Point1 = "Robloxclassicred",
- Point2 = "Pal Hair",
- Middle1 = "Pink Hair",
- Middle2 = "Hat1",
- Ring1 = "Kate Hair",
- Ring2 = "LavanderHair",
- Pinki1 = "Bedhead",
- Pinki2 = "BlockheadBaseballCap",
- Thumb = "MessyHair"
- }
- -- Verify required hats
- local function verifyHats()
- for partName, hatName in pairs(HAT_CONFIGURATION) do
- if not Character:FindFirstChild(hatName) then
- warn("[HatHub] Missing hat: "..hatName.." ("..partName..")")
- return false
- end
- end
- return true
- end
- if not verifyHats() then
- warn("[HatHub] Missing required hats - script disabled")
- return
- end
- -- Physics optimization (client-side only)
- local function optimizePhysics()
- settings().Physics.AllowSleep = false
- local function optimizeCharacterParts()
- for _, part in pairs(Character:GetDescendants()) do
- if part:IsA("BasePart") then
- part.CanCollide = false
- part.Massless = true
- part.CollisionGroup = "Player"
- part.AssemblyLinearVelocity = Vector3.new()
- part.AssemblyAngularVelocity = Vector3.new()
- end
- end
- end
- -- Run optimization periodically
- local heartbeatConnection
- heartbeatConnection = game:GetService("RunService").Heartbeat:Connect(function()
- optimizeCharacterParts()
- end)
- -- Initial optimization
- optimizeCharacterParts()
- return heartbeatConnection
- end
- local physicsConnection = optimizePhysics()
- -- Hand parts initialization
- local HAND_PARTS = {
- Palm = Character[HAT_CONFIGURATION.Palm].Handle,
- Point1 = Character[HAT_CONFIGURATION.Point1].Handle,
- Point2 = Character[HAT_CONFIGURATION.Point2].Handle,
- Middle1 = Character[HAT_CONFIGURATION.Middle1].Handle,
- Middle2 = Character[HAT_CONFIGURATION.Middle2].Handle,
- Ring1 = Character[HAT_CONFIGURATION.Ring1].Handle,
- Ring2 = Character[HAT_CONFIGURATION.Ring2].Handle,
- Pinki1 = Character[HAT_CONFIGURATION.Pinki1].Handle,
- Pinki2 = Character[HAT_CONFIGURATION.Pinki2].Handle,
- Thumb = Character[HAT_CONFIGURATION.Thumb].Handle
- }
- -- Cleanup existing constraints and meshes
- for _, part in pairs(HAND_PARTS) do
- for _, child in pairs(part:GetChildren()) do
- if child:IsA("SpecialMesh") or child:IsA("WeldConstraint") or child:IsA("Weld") then
- child:Destroy()
- end
- end
- -- Ensure each part has an attachment
- if not part:FindFirstChildOfClass("Attachment") then
- Instance.new("Attachment", part)
- end
- end
- -- Create control attachments on HumanoidRootPart
- local CONTROL_ATTACHMENTS = {}
- for i = 1, 10 do
- local attachment = Instance.new("Attachment", HumanoidRootPart)
- attachment.Name = "HandControl_"..i
- table.insert(CONTROL_ATTACHMENTS, attachment)
- end
- -- Alignment system (using Motor6D for better sync)
- local function createAlignment(part, controlAttachment)
- local motor = Instance.new("Motor6D")
- motor.Name = "HandAlignment"
- motor.Part0 = controlAttachment.Parent
- motor.Part1 = part
- motor.C0 = controlAttachment.CFrame
- motor.C1 = part.CFrame:inverse() * controlAttachment.CFrame
- motor.Parent = controlAttachment.Parent
- -- Add velocity constraint for smoother movement
- local alignPos = Instance.new("AlignPosition", part)
- alignPos.Attachment0 = part:FindFirstChildOfClass("Attachment")
- alignPos.Attachment1 = controlAttachment
- alignPos.RigidityEnabled = false
- alignPos.ReactionForceEnabled = false
- alignPos.MaxForce = 50000
- alignPos.Responsiveness = 100
- local alignOri = Instance.new("AlignOrientation", part)
- alignOri.Attachment0 = part:FindFirstChildOfClass("Attachment")
- alignOri.Attachment1 = controlAttachment
- alignOri.ReactionTorqueEnabled = false
- alignOri.MaxTorque = 50000
- alignOri.Responsiveness = 100
- return {
- Motor = motor,
- AlignPosition = alignPos,
- AlignOrientation = alignOri
- }
- end
- -- Create alignments for all hand parts
- local alignments = {
- Palm = createAlignment(HAND_PARTS.Palm, CONTROL_ATTACHMENTS[1]),
- Point1 = createAlignment(HAND_PARTS.Point1, CONTROL_ATTACHMENTS[2]),
- Point2 = createAlignment(HAND_PARTS.Point2, CONTROL_ATTACHMENTS[3]),
- Middle1 = createAlignment(HAND_PARTS.Middle1, CONTROL_ATTACHMENTS[4]),
- Middle2 = createAlignment(HAND_PARTS.Middle2, CONTROL_ATTACHMENTS[5]),
- Ring1 = createAlignment(HAND_PARTS.Ring1, CONTROL_ATTACHMENTS[6]),
- Ring2 = createAlignment(HAND_PARTS.Ring2, CONTROL_ATTACHMENTS[7]),
- Pinki1 = createAlignment(HAND_PARTS.Pinki1, CONTROL_ATTACHMENTS[8]),
- Pinki2 = createAlignment(HAND_PARTS.Pinki2, CONTROL_ATTACHMENTS[9]),
- Thumb = createAlignment(HAND_PARTS.Thumb, CONTROL_ATTACHMENTS[10])
- }
- -- Default hand pose configuration
- local DEFAULT_POSE = {
- Positions = {
- CONTROL_ATTACHMENTS[1].Position = Vector3.new(0, 5, 5),
- CONTROL_ATTACHMENTS[2].Position = Vector3.new(-2, 6.2, 3.12),
- CONTROL_ATTACHMENTS[3].Position = Vector3.new(-2, 6.4, 1.4),
- CONTROL_ATTACHMENTS[4].Position = Vector3.new(-0.6, 6.2, 3.12),
- CONTROL_ATTACHMENTS[5].Position = Vector3.new(-0.6, 6.4, 1.4),
- CONTROL_ATTACHMENTS[6].Position = Vector3.new(0.7, 6.2, 3.12),
- CONTROL_ATTACHMENTS[7].Position = Vector3.new(0.7, 6.4, 1.4),
- CONTROL_ATTACHMENTS[8].Position = Vector3.new(2, 6.2, 3.12),
- CONTROL_ATTACHMENTS[9].Position = Vector3.new(2, 6.4, 1.4),
- CONTROL_ATTACHMENTS[10].Position = Vector3.new(3, 4.5, 4.7)
- },
- Rotations = {
- Palm = Vector3.new(50, 0, 0),
- Point1 = Vector3.new(-20, 0, 0),
- Point2 = Vector3.new(5, 0, 0),
- Middle1 = Vector3.new(-20, 0, 0),
- Middle2 = Vector3.new(5, 0, 0),
- Ring1 = Vector3.new(-20, 0, 0),
- Ring2 = Vector3.new(5, 0, 0),
- Pinki1 = Vector3.new(-20, 0, 0),
- Pinki2 = Vector3.new(5, 0, 0),
- Thumb = Vector3.new(0, 30, 0)
- }
- }
- -- Pose system
- local currentPose = "default"
- local POSE_CONFIGURATIONS = {
- ["default"] = DEFAULT_POSE,
- ["fist"] = {
- Positions = {
- CONTROL_ATTACHMENTS[1].Position = Vector3.new(0, 3.6, 0),
- CONTROL_ATTACHMENTS[2].Position = Vector3.new(-2, 4.6, -1),
- CONTROL_ATTACHMENTS[3].Position = Vector3.new(-2, 4.1, -2),
- CONTROL_ATTACHMENTS[4].Position = Vector3.new(-0.7, 4.6, -1),
- CONTROL_ATTACHMENTS[5].Position = Vector3.new(-0.7, 4.1, -2),
- CONTROL_ATTACHMENTS[6].Position = Vector3.new(0.7, 4.6, -1),
- CONTROL_ATTACHMENTS[7].Position = Vector3.new(0.7, 4.1, -2),
- CONTROL_ATTACHMENTS[8].Position = Vector3.new(2, 6, 0),
- CONTROL_ATTACHMENTS[9].Position = Vector3.new(-2, 5, -0.5),
- CONTROL_ATTACHMENTS[10].Position = Vector3.new(3.3, 2.6, 0)
- },
- Rotations = {
- Palm = Vector3.new(0, 0, 0),
- Point1 = Vector3.new(-180, 0, 0),
- Point2 = Vector3.new(-270, 0, 0),
- Middle1 = Vector3.new(-180, 0, 0),
- Middle2 = Vector3.new(-270, 0, 0),
- Ring1 = Vector3.new(-180, 0, 0),
- Ring2 = Vector3.new(-270, 0, 0),
- Pinki1 = Vector3.new(90, 0, 0),
- Pinki2 = Vector3.new(90, 0, 0),
- Thumb = Vector3.new(0, 90, 0)
- }
- }
- -- Add more poses here
- }
- local function applyPose(poseName)
- if not POSE_CONFIGURATIONS[poseName] then return end
- currentPose = poseName
- local pose = POSE_CONFIGURATIONS[poseName]
- -- Apply positions
- for attachment, position in pairs(pose.Positions) do
- attachment.Position = position
- end
- -- Apply rotations
- for partName, rotation in pairs(pose.Rotations) do
- HAND_PARTS[partName]:FindFirstChildOfClass("Attachment").Rotation = rotation
- end
- end
- -- Input handling
- local UserInputService = game:GetService("UserInputService")
- local inputConnections = {}
- local function setupInput()
- -- Clear existing connections
- for _, conn in pairs(inputConnections) do
- conn:Disconnect()
- end
- -- New connections
- inputConnections["Q"] = UserInputService.InputBegan:Connect(function(input, gameProcessed)
- if gameProcessed then return end
- if input.KeyCode == Enum.KeyCode.Q then
- applyPose("default")
- end
- end)
- inputConnections["E"] = UserInputService.InputBegan:Connect(function(input, gameProcessed)
- if gameProcessed then return end
- if input.KeyCode == Enum.KeyCode.E then
- applyPose("fist")
- end
- end)
- end
- setupInput()
- -- UI
- local ScreenGui = Instance.new("ScreenGui")
- ScreenGui.Name = "HatHubUI"
- ScreenGui.Parent = game.CoreGui
- ScreenGui.ResetOnSpawn = false
- local Frame = Instance.new("Frame")
- Frame.Parent = ScreenGui
- Frame.Size = UDim2.new(0, 200, 0, 50)
- Frame.Position = UDim2.new(0.5, -100, 1, -100)
- Frame.BackgroundTransparency = 0.7
- Frame.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
- local TextLabel = Instance.new("TextLabel")
- TextLabel.Parent = Frame
- TextLabel.Size = UDim2.new(1, 0, 1, 0)
- TextLabel.Text = "HatHub Hand - Pose: "..currentPose
- TextLabel.BackgroundTransparency = 1
- TextLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
- TextLabel.Font = Enum.Font.SourceSansBold
- TextLabel.TextSize = 18
- -- Update UI
- game:GetService("RunService").Heartbeat:Connect(function()
- TextLabel.Text = string.format("HatHub Hand\nPose: %s", currentPose)
- end)
- -- Initial pose
- applyPose("default")
- -- Cleanup on character reset
- local function onCharacterAdded(newCharacter)
- Character = newCharacter
- Humanoid = Character:WaitForChild("Humanoid")
- HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
- -- Reinitialize everything
- if physicsConnection then
- physicsConnection:Disconnect()
- end
- physicsConnection = optimizePhysics()
- -- Recreate UI if needed
- if not ScreenGui or not ScreenGui.Parent then
- ScreenGui = Instance.new("ScreenGui")
- ScreenGui.Name = "HatHubUI"
- ScreenGui.Parent = game.CoreGui
- end
- applyPose(currentPose)
- end
- LocalPlayer.CharacterAdded:Connect(onCharacterAdded)
- print("[HatHub] Hand script loaded successfully!")
Advertisement
Add Comment
Please, Sign In to add comment