Advertisement
ColdSpecs

Main #1 Heads

Sep 6th, 2023
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.41 KB | None | 0 0
  1. -- Settings
  2. local settings = {
  3. headScale = Vector3.new(5, 5, 5)
  4. }
  5.  
  6. -- Variables
  7. local plr = game:GetService("Players").LocalPlayer
  8. local newSizes = {} -- A table to store the new sizes of the heads
  9. local userInputService = game:GetService("UserInputService") -- Get the UserInputService
  10.  
  11. -- Functions
  12. local function changeHeadSize(object)
  13. if object and object:IsA("Part") then
  14. local originalSize = object.Size
  15. local newSize = settings.headScale -- Use the fixed size here instead of adding to the original size
  16. object.Size = newSize
  17. print(object.Name)
  18. newSizes[object] = newSize -- Store the new size in the table using the object as a key
  19. end
  20. end
  21.  
  22. local function updateHeadSize(player)
  23. local character = player.Character or player.CharacterAdded:Wait()
  24. local head = character:FindFirstChild("Head")
  25. if head and head:IsA("Part") then
  26. if newSizes[head] then -- Check if the head has a new size stored in the table
  27. local size = newSizes[head]
  28. head.Size = size
  29. end
  30. end
  31. end
  32.  
  33. local function checkHeads()
  34. local models = workspace:GetChildren() -- Get all the models in the workspace
  35. local heads = {} -- A table to store all the head parts
  36. for _, model in pairs(models) do -- Loop through all the models
  37. if model:IsA("Model") and model:FindFirstChild("Head") then -- Check if the model has a head part
  38. local head = model.Head
  39. table.insert(heads, head) -- Add the head part to the table
  40. end
  41. end
  42. for _, head in pairs(heads) do -- Loop through all the head parts
  43. changeHeadSize(head) -- Call the function to change the head size
  44. end
  45. end
  46.  
  47. -- Main
  48. checkHeads() -- Call the function once at the start
  49.  
  50. game.Players.PlayerAdded:Connect(function(player) -- Connect the function to the PlayerAdded event
  51. updateHeadSize(player) -- Call the function to update the head size
  52. player.CharacterAdded:Connect(function() -- Connect the function to the CharacterAdded event
  53. updateHeadSize(player) -- Call the function to update the head size
  54. end)
  55. end)
  56.  
  57. workspace.ChildAdded:Connect(function(child) -- Connect the function to the ChildAdded event
  58. if child:IsA("Model") and child:FindFirstChild("Head") then -- Check if the child is a model with a head part
  59. local head = child.Head
  60. changeHeadSize(head) -- Call the function to change the head size
  61. end
  62. end)
  63.  
  64. workspace.ChildRemoved:Connect(function(child) -- Connect the function to the ChildRemoved event
  65. if child:IsA("Model") and child:FindFirstChild("Head") then -- Check if the child is a model with a head part
  66. local head = child.Head
  67. newSizes[head] = nil
  68. end
  69. end)
  70.  
  71. userInputService.InputBegan:Connect(function(inputObject, gameProcessedEvent)
  72. if gameProcessedEvent then return end
  73. local keyCode = inputObject.KeyCode -- Get which key was pressed
  74. if keyCode == Enum.KeyCode.Q then -- Keybind
  75. settings.headScale = Vector3.new(12, 12, 12) -- Units
  76. checkHeads() -- Update all heads
  77. elseif keyCode == Enum.KeyCode.F then -- Keybind
  78. settings.headScale = Vector3.new(7, 7, 7) -- Units
  79. checkHeads() -- Update all heads
  80. elseif keyCode == Enum.KeyCode.Z then -- Keybind
  81. settings.headScale = Vector3.new(1, 1, 1) -- Units
  82. checkHeads() -- Update all heads
  83. end
  84. end)
  85.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement