Advertisement
Braian0121

Sonic.EXE 1.2 Double Script

Aug 29th, 2024
1,080
1
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 1 0
  1. local player = game.Players.LocalPlayer
  2.  
  3. -- Disable the reset button
  4. player:SetAttribute("CanReset", false)
  5.  
  6. -- Function to prevent death
  7. local function preventDeath(character)
  8. local humanoid = character:WaitForChild("Humanoid")
  9.  
  10. -- Prevent the player from dying by setting their health to maximum if it drops
  11. humanoid:GetPropertyChangedSignal("Health"):Connect(function()
  12. if humanoid.Health < humanoid.MaxHealth then
  13. humanoid.Health = humanoid.MaxHealth
  14. end
  15. end)
  16.  
  17. -- Optionally, you can make the humanoid invulnerable
  18. humanoid:SetStateEnabled(Enum.HumanoidStateType.Dead, false)
  19. end
  20.  
  21. -- Connect the function to the player's character
  22. player.CharacterAdded:Connect(preventDeath)
  23. if player.Character then
  24. preventDeath(player.Character)
  25. end
Advertisement
Comments
  • jadegamevrs
    195 days
    # C++ 0.80 KB | 0 0
    1. local player = game.Players.LocalPlayer
    2.  
    3. -- Disable the reset button
    4. player:SetAttribute("CanReset", false)
    5.  
    6. -- Function to prevent death
    7. local function preventDeath(character)
    8.     local humanoid = character:WaitForChild("Humanoid")
    9.  
    10.     -- Prevent the player from dying by setting their health to maximum if it drops
    11.     humanoid:GetPropertyChangedSignal("Health"):Connect(function()
    12.         if humanoid.Health < humanoid.MaxHealth then
    13.             humanoid.Health = humanoid.MaxHealth
    14.         end
    15.     end)
    16.  
    17.     -- Optionally, you can make the humanoid invulnerable
    18.     humanoid:SetStateEnabled(Enum.HumanoidStateType.Dead, false)
    19. end
    20.  
    21. -- Connect the function to the player's character
    22. player.CharacterAdded:Connect(preventDeath)
    23. if player.Character then
    24.    preventDeath(player.Character)
    25. end
Add Comment
Please, Sign In to add comment
Advertisement