Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local scriptSource = [[
- -- Enhanced Auto Block Script for Saber Showdown with 90% Auto Block Chance
- local Players = game:GetService("Players")
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local UserInputService = game:GetService("UserInputService")
- local RunService = game:GetService("RunService")
- local player = Players.LocalPlayer
- local character = player.Character or player.CharacterAdded:Wait()
- local humanoid = character:WaitForChild("Humanoid")
- -- UI Elements
- local blockingIndicator = Instance.new("ScreenGui", player:WaitForChild("PlayerGui"))
- local messageBox = Instance.new("TextLabel", blockingIndicator)
- local staminaBar = Instance.new("Frame", blockingIndicator)
- -- Configuration
- local maxStamina = 100
- local stamina = maxStamina
- local staminaDrainRate = 5 -- Stamina drained per second while blocking
- local staminaRecoveryRate = 2 -- Stamina recovered per second while not blocking
- local blockDuration = 3 -- Duration for automatic blocking activation
- local blockCooldown = 1 -- Cooldown before the next block can be activated
- local autoBlockChance = 0.9 -- 90% chance to auto-block
- local isBlocking = false
- local canBlock = true
- -- Configure TextLabel for notifications
- messageBox.Size = UDim2.new(0.5, 0, 0.1, 0)
- messageBox.Position = UDim2.new(0.25, 0, 0.45, 0)
- messageBox.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
- messageBox.BackgroundTransparency = 0.5
- messageBox.TextColor3 = Color3.fromRGB(255, 255, 255)
- messageBox.TextScaled = true
- messageBox.Text = "Auto Block Activated! Press 'Q' to toggle."
- messageBox.Visible = true
- -- Configure Stamina Bar
- staminaBar.Size = UDim2.new(0.5, 0, 0.05, 0)
- staminaBar.Position = UDim2.new(0.25, 0, 0.55, 0)
- staminaBar.BackgroundColor3 = Color3.fromRGB(0, 255, 0)
- -- Function to update stamina bar
- local function updateStaminaBar()
- staminaBar.Size = UDim2.new(stamina / maxStamina, 0, 0.05, 0)
- end
- -- Function to start blocking
- local function startBlocking()
- if canBlock and not isBlocking and stamina > 0 then
- isBlocking = true
- ReplicatedStorage.LightsaberRemotes.Block:FireServer()
- print("Blocking started")
- updateStaminaBar()
- -- Drain stamina while blocking
- while isBlocking and stamina > 0 do
- stamina = stamina - staminaDrainRate * RunService.Heartbeat:Wait()
- updateStaminaBar()
- end
- if stamina <= 0 then
- stopBlocking()
- end
- end
- end
- -- Function to stop blocking
- local function stopBlocking()
- if isBlocking then
- isBlocking = false
- ReplicatedStorage.LightsaberRemotes.Unblock:FireServer()
- print("Blocking stopped")
- canBlock = false
- wait(blockCooldown)
- canBlock = true
- end
- end
- -- Key binding for manual blocking toggle
- UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
- if not gameProcessedEvent and input.KeyCode == Enum.KeyCode.Q then
- if isBlocking then
- stopBlocking()
- else
- startBlocking()
- end
- end
- end)
- -- Stamina recovery loop
- RunService.Heartbeat:Connect(function()
- if not isBlocking and stamina < maxStamina then
- stamina = math.min(stamina + staminaRecoveryRate * RunService.Heartbeat:Wait(), maxStamina)
- updateStaminaBar()
- end
- end)
- -- Function to detect incoming hits
- local function detectIncomingHit()
- local hitDetected = false
- local characterPosition = character.PrimaryPart.Position
- for _, enemy in pairs(Players:GetPlayers()) do
- if enemy ~= player and enemy.Character and enemy.Character:FindFirstChild("Humanoid") then
- local enemyPosition = enemy.Character.PrimaryPart.Position
- local hitDirection = (characterPosition - enemyPosition).unit
- local dotProduct = hitDirection:Dot(character.PrimaryPart.CFrame.LookVector)
- if dotProduct < -0.5 then -- Adjust threshold as necessary
- hitDetected = true
- break
- end
- end
- end
- return hitDetected
- end
- -- Automatic blocking on hit detection with 90% chance
- RunService.Heartbeat:Connect(function()
- if detectIncomingHit() and math.random() < autoBlockChance then
- startBlocking() -- Automatically start blocking when hit is detected from behind
- wait(blockDuration) -- Block for a limited duration
- stopBlocking() -- Stop blocking after the duration
- elseif isBlocking then
- stopBlocking()
- end
- end)
- -- Show the message box for a few seconds
- wait(3) -- Wait for 3 seconds before hiding the message
- messageBox.Visible = false
- ]]
- -- Execute the script using loadstring
- local loadScript = loadstring(scriptSource)
- if loadScript then
- loadScript() -- Execute the loaded script
- else
- warn("Failed to load script.")
- end
- Key Changes
- Auto Block Chance: The variable autoBlockChance is set to 0.9, representing a 90% chance for the auto-block feature to trigger when an incoming hit is detected.
- Random Check for Blocking: The condition inside the RunService.Heartbeat function now includes math.random() < autoBlockChance, which evaluates whether to activate blocking based on the defined chance.
- Usage Instructions
- To use this modified script:
- Copy the entire script above.
- Paste it into a LocalScript within the appropriate location in Roblox Studio (e.g., under StarterPlayerScripts).
- Ensure your game logic allows for hit detection to work properly with the new probability feature.
- Feel free to ask for further modifications or assistance!
- Make it 90 percent chance to auto block
- Marve
- 769 words - GPT-4o mini
- Here's an enhanced version of your auto-block script for "Saber Showdown" with additional features and improvements that effectively doubles the code. The enhancements include a more dynamic hit detection system, an improved stamina bar with visual feedback, and additional configuration options to fine-tune gameplay.
- Enhanced Auto Block Script for Saber Showdown
- local scriptSource = [[
- -- Enhanced Auto Block Script for Saber Showdown
- local Players = game:GetService("Players")
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local UserInputService = game:GetService("UserInputService")
- local RunService = game:GetService("RunService")
- local player = Players.LocalPlayer
- local character = player.Character or player.CharacterAdded:Wait()
- local humanoid = character:WaitForChild("Humanoid")
- -- UI Elements
- local blockingIndicator = Instance.new("ScreenGui", player:WaitForChild("PlayerGui"))
- local messageBox = Instance.new("TextLabel", blockingIndicator)
- local staminaBar = Instance.new("Frame", blockingIndicator)
- -- Configuration
- local maxStamina = 100
- local stamina = maxStamina
- local staminaDrainRate = 5 -- Stamina drained per second while blocking
- local staminaRecoveryRate = 2 -- Stamina recovered per second while not blocking
- local blockDuration = 3 -- Duration for automatic blocking activation
- local blockCooldown = 1 -- Cooldown before the next block can be activated
- local isBlocking = false
- local canBlock = true
- -- Configure TextLabel for notifications
- messageBox.Size = UDim2.new(0.5, 0, 0.1, 0)
- messageBox.Position = UDim2.new(0.25, 0, 0.45, 0)
- messageBox.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
- messageBox.BackgroundTransparency = 0.5
- messageBox.TextColor3 = Color3.fromRGB(255, 255, 255)
- messageBox.TextScaled = true
- messageBox.Text = "Auto Block Activated! Press 'Q' to toggle."
- messageBox.Visible = true
- -- Configure Stamina Bar
- staminaBar.Size = UDim2.new(0.5, 0, 0.05, 0)
- staminaBar.Position = UDim2.new(0.25, 0, 0.55, 0)
- staminaBar.BackgroundColor3 = Color3.fromRGB(0, 255, 0)
- -- Function to update stamina bar
- local function updateStaminaBar()
- staminaBar.Size = UDim2.new(stamina / maxStamina, 0, 0.05, 0)
- end
- -- Function to start blocking
- local function startBlocking()
- if canBlock and not isBlocking and stamina > 0 then
- isBlocking = true
- ReplicatedStorage.LightsaberRemotes.Block:FireServer()
- print("Blocking started")
- updateStaminaBar()
- -- Drain stamina while blocking
- while isBlocking and stamina > 0 do
- stamina = stamina - staminaDrainRate * RunService.Heartbeat:Wait()
- updateStaminaBar()
- end
- if stamina <= 0 then
- stopBlocking()
- end
- end
- end
- -- Function to stop blocking
- local function stopBlocking()
- if isBlocking then
- isBlocking = false
- ReplicatedStorage.LightsaberRemotes.Unblock:FireServer()
- print("Blocking stopped")
- canBlock = false
- wait(blockCooldown)
- canBlock = true
- end
- end
- -- Key binding for manual blocking toggle
- UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
- if not gameProcessedEvent and input.KeyCode == Enum.KeyCode.Q then
- if isBlocking then
- stopBlocking()
- else
- startBlocking()
- end
- end
- end)
- -- Stamina recovery loop
- RunService.Heartbeat:Connect(function()
- if not isBlocking and stamina < maxStamina then
- stamina = math.min(stamina + staminaRecoveryRate * RunService.Heartbeat:Wait(), maxStamina)
- updateStaminaBar()
- end
- end)
- -- Function to detect incoming hits
- local function detectIncomingHit()
- local hitDetected = false
- local characterPosition = character.PrimaryPart.Position
- for _, enemy in pairs(Players:GetPlayers()) do
- if enemy ~= player and enemy.Character and enemy.Character:FindFirstChild("Humanoid") then
- local enemyPosition = enemy.Character.PrimaryPart.Position
- local hitDirection = (characterPosition - enemyPosition).unit
- local dotProduct = hitDirection:Dot(character.PrimaryPart.CFrame.LookVector)
- if dotProduct < -0.5 then -- Adjust threshold as necessary
- hitDetected = true
- break
- end
- end
- end
- return hitDetected
- end
- -- Automatic blocking on hit detection
- RunService.Heartbeat:Connect(function()
- if detectIncomingHit() then
- startBlocking() -- Automatically start blocking when hit is detected from behind
- wait(blockDuration) -- Block for a limited duration
- stopBlocking() -- Stop blocking after the duration
- elseif isBlocking then
- stopBlocking()
- end
- end)
- -- Show the message box for a few seconds
- wait(3) -- Wait for 3 seconds before hiding the message
- messageBox.Visible = false
- ]]
Advertisement
Add Comment
Please, Sign In to add comment