Guest User

Untitled

a guest
Aug 18th, 2024
4,647
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.37 KB | None | 1 0
  1. local scriptSource = [[
  2. -- Enhanced Auto Block Script for Saber Showdown with 90% Auto Block Chance
  3. local Players = game:GetService("Players")
  4. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  5. local UserInputService = game:GetService("UserInputService")
  6. local RunService = game:GetService("RunService")
  7.  
  8. local player = Players.LocalPlayer
  9. local character = player.Character or player.CharacterAdded:Wait()
  10. local humanoid = character:WaitForChild("Humanoid")
  11.  
  12. -- UI Elements
  13. local blockingIndicator = Instance.new("ScreenGui", player:WaitForChild("PlayerGui"))
  14. local messageBox = Instance.new("TextLabel", blockingIndicator)
  15. local staminaBar = Instance.new("Frame", blockingIndicator)
  16.  
  17. -- Configuration
  18. local maxStamina = 100
  19. local stamina = maxStamina
  20. local staminaDrainRate = 5 -- Stamina drained per second while blocking
  21. local staminaRecoveryRate = 2 -- Stamina recovered per second while not blocking
  22. local blockDuration = 3 -- Duration for automatic blocking activation
  23. local blockCooldown = 1 -- Cooldown before the next block can be activated
  24. local autoBlockChance = 0.9 -- 90% chance to auto-block
  25.  
  26. local isBlocking = false
  27. local canBlock = true
  28.  
  29. -- Configure TextLabel for notifications
  30. messageBox.Size = UDim2.new(0.5, 0, 0.1, 0)
  31. messageBox.Position = UDim2.new(0.25, 0, 0.45, 0)
  32. messageBox.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
  33. messageBox.BackgroundTransparency = 0.5
  34. messageBox.TextColor3 = Color3.fromRGB(255, 255, 255)
  35. messageBox.TextScaled = true
  36. messageBox.Text = "Auto Block Activated! Press 'Q' to toggle."
  37. messageBox.Visible = true
  38.  
  39. -- Configure Stamina Bar
  40. staminaBar.Size = UDim2.new(0.5, 0, 0.05, 0)
  41. staminaBar.Position = UDim2.new(0.25, 0, 0.55, 0)
  42. staminaBar.BackgroundColor3 = Color3.fromRGB(0, 255, 0)
  43.  
  44. -- Function to update stamina bar
  45. local function updateStaminaBar()
  46. staminaBar.Size = UDim2.new(stamina / maxStamina, 0, 0.05, 0)
  47. end
  48.  
  49. -- Function to start blocking
  50. local function startBlocking()
  51. if canBlock and not isBlocking and stamina > 0 then
  52. isBlocking = true
  53. ReplicatedStorage.LightsaberRemotes.Block:FireServer()
  54. print("Blocking started")
  55. updateStaminaBar()
  56.  
  57. -- Drain stamina while blocking
  58. while isBlocking and stamina > 0 do
  59. stamina = stamina - staminaDrainRate * RunService.Heartbeat:Wait()
  60. updateStaminaBar()
  61. end
  62.  
  63. if stamina <= 0 then
  64. stopBlocking()
  65. end
  66. end
  67. end
  68.  
  69. -- Function to stop blocking
  70. local function stopBlocking()
  71. if isBlocking then
  72. isBlocking = false
  73. ReplicatedStorage.LightsaberRemotes.Unblock:FireServer()
  74. print("Blocking stopped")
  75. canBlock = false
  76. wait(blockCooldown)
  77. canBlock = true
  78. end
  79. end
  80.  
  81. -- Key binding for manual blocking toggle
  82. UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
  83. if not gameProcessedEvent and input.KeyCode == Enum.KeyCode.Q then
  84. if isBlocking then
  85. stopBlocking()
  86. else
  87. startBlocking()
  88. end
  89. end
  90. end)
  91.  
  92. -- Stamina recovery loop
  93. RunService.Heartbeat:Connect(function()
  94. if not isBlocking and stamina < maxStamina then
  95. stamina = math.min(stamina + staminaRecoveryRate * RunService.Heartbeat:Wait(), maxStamina)
  96. updateStaminaBar()
  97. end
  98. end)
  99.  
  100. -- Function to detect incoming hits
  101. local function detectIncomingHit()
  102. local hitDetected = false
  103. local characterPosition = character.PrimaryPart.Position
  104.  
  105. for _, enemy in pairs(Players:GetPlayers()) do
  106. if enemy ~= player and enemy.Character and enemy.Character:FindFirstChild("Humanoid") then
  107. local enemyPosition = enemy.Character.PrimaryPart.Position
  108. local hitDirection = (characterPosition - enemyPosition).unit
  109. local dotProduct = hitDirection:Dot(character.PrimaryPart.CFrame.LookVector)
  110.  
  111. if dotProduct < -0.5 then -- Adjust threshold as necessary
  112. hitDetected = true
  113. break
  114. end
  115. end
  116. end
  117. return hitDetected
  118. end
  119.  
  120. -- Automatic blocking on hit detection with 90% chance
  121. RunService.Heartbeat:Connect(function()
  122. if detectIncomingHit() and math.random() < autoBlockChance then
  123. startBlocking() -- Automatically start blocking when hit is detected from behind
  124. wait(blockDuration) -- Block for a limited duration
  125. stopBlocking() -- Stop blocking after the duration
  126. elseif isBlocking then
  127. stopBlocking()
  128. end
  129. end)
  130.  
  131. -- Show the message box for a few seconds
  132. wait(3) -- Wait for 3 seconds before hiding the message
  133. messageBox.Visible = false
  134. ]]
  135.  
  136. -- Execute the script using loadstring
  137. local loadScript = loadstring(scriptSource)
  138. if loadScript then
  139. loadScript() -- Execute the loaded script
  140. else
  141. warn("Failed to load script.")
  142. end
  143. Key Changes
  144. 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.
  145.  
  146. 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.
  147.  
  148. Usage Instructions
  149. To use this modified script:
  150.  
  151. Copy the entire script above.
  152. Paste it into a LocalScript within the appropriate location in Roblox Studio (e.g., under StarterPlayerScripts).
  153. Ensure your game logic allows for hit detection to work properly with the new probability feature.
  154. Feel free to ask for further modifications or assistance!
  155.  
  156.  
  157. Make it 90 percent chance to auto block
  158.  
  159.  
  160. Marve
  161. 769 words - GPT-4o mini
  162. 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.
  163.  
  164. Enhanced Auto Block Script for Saber Showdown
  165. local scriptSource = [[
  166. -- Enhanced Auto Block Script for Saber Showdown
  167. local Players = game:GetService("Players")
  168. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  169. local UserInputService = game:GetService("UserInputService")
  170. local RunService = game:GetService("RunService")
  171.  
  172. local player = Players.LocalPlayer
  173. local character = player.Character or player.CharacterAdded:Wait()
  174. local humanoid = character:WaitForChild("Humanoid")
  175.  
  176. -- UI Elements
  177. local blockingIndicator = Instance.new("ScreenGui", player:WaitForChild("PlayerGui"))
  178. local messageBox = Instance.new("TextLabel", blockingIndicator)
  179. local staminaBar = Instance.new("Frame", blockingIndicator)
  180.  
  181. -- Configuration
  182. local maxStamina = 100
  183. local stamina = maxStamina
  184. local staminaDrainRate = 5 -- Stamina drained per second while blocking
  185. local staminaRecoveryRate = 2 -- Stamina recovered per second while not blocking
  186. local blockDuration = 3 -- Duration for automatic blocking activation
  187. local blockCooldown = 1 -- Cooldown before the next block can be activated
  188.  
  189. local isBlocking = false
  190. local canBlock = true
  191.  
  192. -- Configure TextLabel for notifications
  193. messageBox.Size = UDim2.new(0.5, 0, 0.1, 0)
  194. messageBox.Position = UDim2.new(0.25, 0, 0.45, 0)
  195. messageBox.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
  196. messageBox.BackgroundTransparency = 0.5
  197. messageBox.TextColor3 = Color3.fromRGB(255, 255, 255)
  198. messageBox.TextScaled = true
  199. messageBox.Text = "Auto Block Activated! Press 'Q' to toggle."
  200. messageBox.Visible = true
  201.  
  202. -- Configure Stamina Bar
  203. staminaBar.Size = UDim2.new(0.5, 0, 0.05, 0)
  204. staminaBar.Position = UDim2.new(0.25, 0, 0.55, 0)
  205. staminaBar.BackgroundColor3 = Color3.fromRGB(0, 255, 0)
  206.  
  207. -- Function to update stamina bar
  208. local function updateStaminaBar()
  209. staminaBar.Size = UDim2.new(stamina / maxStamina, 0, 0.05, 0)
  210. end
  211.  
  212. -- Function to start blocking
  213. local function startBlocking()
  214. if canBlock and not isBlocking and stamina > 0 then
  215. isBlocking = true
  216. ReplicatedStorage.LightsaberRemotes.Block:FireServer()
  217. print("Blocking started")
  218. updateStaminaBar()
  219.  
  220. -- Drain stamina while blocking
  221. while isBlocking and stamina > 0 do
  222. stamina = stamina - staminaDrainRate * RunService.Heartbeat:Wait()
  223. updateStaminaBar()
  224. end
  225.  
  226. if stamina <= 0 then
  227. stopBlocking()
  228. end
  229. end
  230. end
  231.  
  232. -- Function to stop blocking
  233. local function stopBlocking()
  234. if isBlocking then
  235. isBlocking = false
  236. ReplicatedStorage.LightsaberRemotes.Unblock:FireServer()
  237. print("Blocking stopped")
  238. canBlock = false
  239. wait(blockCooldown)
  240. canBlock = true
  241. end
  242. end
  243.  
  244. -- Key binding for manual blocking toggle
  245. UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
  246. if not gameProcessedEvent and input.KeyCode == Enum.KeyCode.Q then
  247. if isBlocking then
  248. stopBlocking()
  249. else
  250. startBlocking()
  251. end
  252. end
  253. end)
  254.  
  255. -- Stamina recovery loop
  256. RunService.Heartbeat:Connect(function()
  257. if not isBlocking and stamina < maxStamina then
  258. stamina = math.min(stamina + staminaRecoveryRate * RunService.Heartbeat:Wait(), maxStamina)
  259. updateStaminaBar()
  260. end
  261. end)
  262.  
  263. -- Function to detect incoming hits
  264. local function detectIncomingHit()
  265. local hitDetected = false
  266. local characterPosition = character.PrimaryPart.Position
  267.  
  268. for _, enemy in pairs(Players:GetPlayers()) do
  269. if enemy ~= player and enemy.Character and enemy.Character:FindFirstChild("Humanoid") then
  270. local enemyPosition = enemy.Character.PrimaryPart.Position
  271. local hitDirection = (characterPosition - enemyPosition).unit
  272. local dotProduct = hitDirection:Dot(character.PrimaryPart.CFrame.LookVector)
  273.  
  274. if dotProduct < -0.5 then -- Adjust threshold as necessary
  275. hitDetected = true
  276. break
  277. end
  278. end
  279. end
  280. return hitDetected
  281. end
  282.  
  283. -- Automatic blocking on hit detection
  284. RunService.Heartbeat:Connect(function()
  285. if detectIncomingHit() then
  286. startBlocking() -- Automatically start blocking when hit is detected from behind
  287. wait(blockDuration) -- Block for a limited duration
  288. stopBlocking() -- Stop blocking after the duration
  289. elseif isBlocking then
  290. stopBlocking()
  291. end
  292. end)
  293.  
  294. -- Show the message box for a few seconds
  295. wait(3) -- Wait for 3 seconds before hiding the message
  296. messageBox.Visible = false
  297. ]]
  298.  
Advertisement
Add Comment
Please, Sign In to add comment