Advertisement
Guest User

Invincible script for roblox

a guest
Jun 20th, 2024
5,638
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. -- Create a Screen GUI
  2. local ScreenGui = Instance.new("ScreenGui")
  3. ScreenGui.Name = "InvincibilityGUI"
  4. ScreenGui.ResetOnSpawn = false
  5. ScreenGui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
  6.  
  7. -- Function to toggle player's invincibility
  8. local function toggleInvincibility()
  9. -- Get the player's character
  10. local player = game.Players.LocalPlayer
  11. local character = player.Character
  12. if not character then
  13. return
  14. end
  15.  
  16. -- Toggle invincibility
  17. local humanoid = character:FindFirstChildOfClass("Humanoid")
  18. if humanoid then
  19. humanoid.MaxHealth = math.huge -- Set max health to a very large number to effectively make player invincible
  20. humanoid.Health = math.huge -- Set health to a very large number to ensure player doesn't die
  21. humanoid:TakeDamage(0) -- Make sure player is not currently taking damage
  22. end
  23. end
  24.  
  25. -- Create a TextButton for the "Invincible" button
  26. local invincibleButton = Instance.new("TextButton")
  27. invincibleButton.Size = UDim2.new(0, 200, 0, 50) -- Size of the button
  28. invincibleButton.Position = UDim2.new(0.75, 0, 0.1, 0) -- Position of the button (adjust as needed)
  29. invincibleButton.Text = "Invincible"
  30. invincibleButton.TextColor3 = Color3.fromRGB(255, 255, 255) -- Text color (white)
  31. invincibleButton.BackgroundColor3 = Color3.fromRGB(0, 120, 215) -- Button color (blue)
  32. invincibleButton.Font = Enum.Font.SourceSans
  33. invincibleButton.FontSize = Enum.FontSize.Size24
  34. invincibleButton.Parent = ScreenGui
  35.  
  36. -- Connect button click event to the function that toggles invincibility
  37. invincibleButton.MouseButton1Click:Connect(toggleInvincibility)
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement