Guest User

Chams script

a guest
Sep 29th, 2024
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.31 KB | Source Code | 0 0
  1. -- Variables
  2. local players = game:GetService("Players")
  3. local localPlayer = players.LocalPlayer
  4. local playerGui = localPlayer:WaitForChild("PlayerGui")
  5.  
  6. local chamsEnabled = false
  7.  
  8. -- Create the ScreenGui
  9. local screenGui = Instance.new("ScreenGui")
  10. screenGui.Name = "ChamsScreenGui"
  11. screenGui.Parent = playerGui -- Attach the ScreenGui to the player's GUI
  12.  
  13. -- Create the ToggleButton
  14. local toggleButton = Instance.new("TextButton")
  15. toggleButton.Name = "ToggleButton"
  16. toggleButton.Text = "Enable Chams"
  17. toggleButton.Position = UDim2.new(0.4, 0, 0.1, 0) -- Centered on the screen
  18. toggleButton.Size = UDim2.new(0.2, 0, 0.1, 0)
  19. toggleButton.TextColor3 = Color3.new(1, 1, 1) -- White text
  20. toggleButton.BackgroundColor3 = Color3.new(0, 0, 0) -- Black background
  21. toggleButton.Parent = screenGui -- Attach the button to the ScreenGui
  22.  
  23. -- Function to add Chams (BoxHandleAdornment)
  24. local function addChams(player)
  25. if player.Character then
  26. for _, part in pairs(player.Character:GetChildren()) do
  27. if part:IsA("BasePart") then
  28. -- Create the BoxHandleAdornment
  29. local chams = Instance.new("BoxHandleAdornment")
  30. chams.Name = "Chams"
  31. chams.AlwaysOnTop = true -- Makes it visible through walls
  32. chams.ZIndex = 0 -- Layering control
  33. chams.Adornee = part -- Attach it to the player's body part
  34. chams.Color3 = Color3.new(0, 1, 0) -- Green color (you can change this)
  35. chams.Transparency = 0.3 -- Adjust transparency (lower is more visible)
  36. chams.Size = part.Size + Vector3.new(0.1, 0.1, 0.1) -- Slightly larger than the part
  37. chams.Parent = part -- Parent it to the part so it stays with the character
  38. end
  39. end
  40. end
  41. end
  42.  
  43. -- Function to remove Chams (BoxHandleAdornment)
  44. local function removeChams(player)
  45. if player.Character then
  46. for _, part in pairs(player.Character:GetChildren()) do
  47. if part:IsA("BasePart") then
  48. local cham = part:FindFirstChild("Chams")
  49. if cham then
  50. cham:Destroy() -- Remove the Chams adornment
  51. end
  52. end
  53. end
  54. end
  55. end
  56.  
  57. -- Function to toggle Chams for all players
  58. local function toggleChams()
  59. if chamsEnabled then
  60. -- Disable Chams
  61. for _, player in pairs(players:GetPlayers()) do
  62. if player ~= localPlayer then
  63. removeChams(player)
  64. end
  65. end
  66. else
  67. -- Enable Chams
  68. for _, player in pairs(players:GetPlayers()) do
  69. if player ~= localPlayer then
  70. addChams(player)
  71. end
  72. end
  73. end
  74. chamsEnabled = not chamsEnabled
  75. toggleButton.Text = chamsEnabled and "Disable Chams" or "Enable Chams"
  76. end
  77.  
  78. -- Toggle Chams on button click
  79. toggleButton.MouseButton1Click:Connect(function()
  80. toggleChams()
  81. end)
  82.  
  83. -- Add Chams when a new player joins the game
  84. players.PlayerAdded:Connect(function(player)
  85. player.CharacterAdded:Connect(function()
  86. if chamsEnabled then
  87. addChams(player)
  88. end
  89. end)
  90. end)
  91.  
  92. -- Remove Chams when a player leaves the game
  93. players.PlayerRemoving:Connect(function(player)
  94. removeChams(player)
  95. end)
Tags: Script
Advertisement
Add Comment
Please, Sign In to add comment