Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Create a Screen GUI
- local ScreenGui = Instance.new("ScreenGui")
- ScreenGui.Name = "InvincibilityGUI"
- ScreenGui.ResetOnSpawn = false
- ScreenGui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
- -- Function to toggle player's invincibility
- local function toggleInvincibility()
- -- Get the player's character
- local player = game.Players.LocalPlayer
- local character = player.Character
- if not character then
- return
- end
- -- Toggle invincibility
- local humanoid = character:FindFirstChildOfClass("Humanoid")
- if humanoid then
- humanoid.MaxHealth = math.huge -- Set max health to a very large number to effectively make player invincible
- humanoid.Health = math.huge -- Set health to a very large number to ensure player doesn't die
- humanoid:TakeDamage(0) -- Make sure player is not currently taking damage
- end
- end
- -- Create a TextButton for the "Invincible" button
- local invincibleButton = Instance.new("TextButton")
- invincibleButton.Size = UDim2.new(0, 200, 0, 50) -- Size of the button
- invincibleButton.Position = UDim2.new(0.75, 0, 0.1, 0) -- Position of the button (adjust as needed)
- invincibleButton.Text = "Invincible"
- invincibleButton.TextColor3 = Color3.fromRGB(255, 255, 255) -- Text color (white)
- invincibleButton.BackgroundColor3 = Color3.fromRGB(0, 120, 215) -- Button color (blue)
- invincibleButton.Font = Enum.Font.SourceSans
- invincibleButton.FontSize = Enum.FontSize.Size24
- invincibleButton.Parent = ScreenGui
- -- Connect button click event to the function that toggles invincibility
- invincibleButton.MouseButton1Click:Connect(toggleInvincibility)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement