Advertisement
Ultimate_69

Gladiator System

Mar 31st, 2025
16
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.84 KB | None | 0 0
  1. -- CLIENT LOCAL SCRIPT
  2.  
  3. local tool = script.Parent
  4. local uis = game:GetService("UserInputService")
  5. local rs = game:GetService("RunService")
  6. local plr = game.Players.LocalPlayer
  7. local ShiftLock = require(plr:WaitForChild("PlayerScripts"):WaitForChild("CustomShiftLock"):WaitForChild("SmoothShiftLock"))
  8. local char = plr.Character
  9. local hum = char:WaitForChild("Humanoid")
  10. local equipped = false
  11. local remote = game.ReplicatedStorage.Remotes.GladiusRemote
  12. local swordRemote = game.ReplicatedStorage.Remotes.GladiusSwordRemote
  13. local shieldRotationRemote = game.ReplicatedStorage.Remotes.RotationRemote
  14. local attributeRemote = game.ReplicatedStorage.Remotes.AttributeRemote
  15.  
  16. local debounce = false
  17. local doubleDebounce = false
  18. local thurstUp = false
  19. local isCharging = false
  20. local isCharged = false
  21. local animEnded = true
  22. local lastAttackPos = nil
  23.  
  24. local coolDownTime = 1
  25.  
  26. local connections = {}
  27.  
  28. local idleTrack = hum:LoadAnimation(game.ReplicatedStorage.Animations.Gladius.GladiusPose)
  29. local blockUpTrack = hum:LoadAnimation(game.ReplicatedStorage.Animations.Gladius.GladiusBlock)
  30. local blockLowTrack = hum:LoadAnimation(game.ReplicatedStorage.Animations.Gladius.GladiusBlockLow)
  31. local thrustLowTrack = hum:LoadAnimation(game.ReplicatedStorage.Animations.Gladius.GladiusThrustLow)
  32. local thrustUpTrack = hum:LoadAnimation(game.ReplicatedStorage.Animations.Gladius.GladiusThrustUp)
  33. local thrustLowHitTrack = hum:LoadAnimation(game.ReplicatedStorage.Animations.Gladius.GladiusThrustLowHit)
  34. local thrustUpHitTrack = hum:LoadAnimation(game.ReplicatedStorage.Animations.Gladius.GladiusThrustUpHit)
  35.  
  36. thrustUpHitTrack.Stopped:Connect(function()
  37. animEnded = true
  38. end)
  39.  
  40. thrustLowHitTrack.Stopped:Connect(function()
  41. animEnded = true
  42. end)
  43.  
  44. local shieldWeld: Weld = plr.Character:WaitForChild("Shield"):WaitForChild("Meshes/Shield G"):WaitForChild("ShieldWeldTemplate")
  45.  
  46. local gui = script.Parent.WeaponGui:Clone()
  47. gui.Parent = plr.PlayerGui
  48.  
  49. local function EndCooldown()
  50. debounce = false
  51. gui.CanHit.ImageLabel.ImageColor3 = Color3.new(1, 1, 1)
  52. lastAttackPos = nil
  53. end
  54.  
  55. local function EndDoubleCooldown()
  56. doubleDebounce = false
  57. gui.CanHit.ImageLabel.ImageColor3 = Color3.new(1, 1, 1)
  58. end
  59.  
  60. local function RemoveConnections()
  61. for i,v in pairs(connections) do
  62. v:Disconnect()
  63. end
  64. table.clear(connections)
  65. end
  66.  
  67. local function UpOrDown()
  68. return workspace.CurrentCamera.CFrame.LookVector.Y
  69. end
  70.  
  71. rs.Heartbeat:Connect(function(deltaTime)
  72. thurstUp = UpOrDown() >= -0.3
  73.  
  74. if thurstUp then
  75. gui.Crosshair.Frame.TopBlock.ImageTransparency = 0
  76. gui.Crosshair.Frame.BottomBlock.ImageTransparency = 1
  77. else
  78. gui.Crosshair.Frame.TopBlock.ImageTransparency = 1
  79. gui.Crosshair.Frame.BottomBlock.ImageTransparency = 0
  80. end
  81. end)
  82.  
  83. tool.Equipped:Connect(function()
  84. equipped = true
  85.  
  86. thurstUp = true
  87. gui.Enabled = true
  88.  
  89. swordRemote:FireServer(plr.Character:WaitForChild("Sword"):WaitForChild("Meshes/Espada Um a Tres_SM_Sword_Gladius_02_LOD0"), 1)
  90. ShiftLock:ToggleShiftLock(true)
  91. uis.MouseIconEnabled = false
  92.  
  93. idleTrack:Play()
  94. end)
  95.  
  96. tool.Unequipped:Connect(function()
  97. equipped = false
  98. gui.Enabled = false
  99.  
  100. swordRemote:FireServer(plr.Character:WaitForChild("Sword"):WaitForChild("Meshes/Espada Um a Tres_SM_Sword_Gladius_02_LOD0"), 0)
  101. ShiftLock:ToggleShiftLock(false)
  102. uis.MouseIconEnabled = true
  103.  
  104. idleTrack:Stop()
  105. blockUpTrack:Stop()
  106. blockLowTrack:Stop()
  107. end)
  108.  
  109. uis.InputBegan:Connect(function(input, process)
  110. if process then return end
  111.  
  112. if input.UserInputType == Enum.UserInputType.MouseButton1 then
  113. if not equipped then return end
  114. if debounce then return end
  115. if plr.Character:GetAttribute("State") == "Default" then
  116. if not isCharging then
  117. isCharging = true
  118. if thurstUp then
  119. if lastAttackPos == "Up" then
  120. isCharging = false
  121. debounce = true
  122. task.delay(1, EndCooldown)
  123. return
  124. end
  125. attributeRemote:FireServer("State", "Attacking")
  126. attributeRemote:FireServer("AttackPos", "Up")
  127. lastAttackPos = "Up"
  128. thrustUpTrack:Play()
  129. thrustUpTrack:AdjustSpeed(0.8)
  130. local connect = thrustUpTrack:GetMarkerReachedSignal("Stop"):Connect(function()
  131. thrustUpTrack:AdjustSpeed(0)
  132. isCharged = true
  133. gui.CanHit.ImageLabel.ImageColor3 = Color3.new(1, 0, 0)
  134. doubleDebounce = true
  135. task.delay(coolDownTime, EndDoubleCooldown)
  136. end)
  137. table.insert(connections, connect)
  138. elseif not thurstUp then
  139. if lastAttackPos == "Down" then
  140. isCharging = false
  141. debounce = true
  142. task.delay(1, EndCooldown)
  143. return
  144. end
  145. attributeRemote:FireServer("State", "Attacking")
  146. attributeRemote:FireServer("AttackPos", "Down")
  147. lastAttackPos = "Down"
  148. thrustLowTrack:Play()
  149. thrustLowTrack:AdjustSpeed(0.8)
  150. local connect = thrustLowTrack:GetMarkerReachedSignal("Stop"):Connect(function()
  151. thrustLowTrack:AdjustSpeed(0)
  152. isCharged = true
  153. gui.CanHit.ImageLabel.ImageColor3 = Color3.new(1, 0, 0)
  154. doubleDebounce = true
  155. task.delay(coolDownTime, EndDoubleCooldown)
  156. end)
  157. table.insert(connections, connect)
  158. end
  159. end
  160. end
  161. end
  162.  
  163. if input.UserInputType == Enum.UserInputType.MouseButton2 then
  164. if not equipped then return end
  165. if not animEnded then return end
  166. if isCharging then
  167. isCharging = false
  168. isCharged = false
  169. attributeRemote:FireServer("State", "Default")
  170. thrustUpTrack:Stop()
  171. thrustLowTrack:Stop()
  172. end
  173. if thurstUp then
  174. attributeRemote:FireServer("State", "Blocking")
  175. attributeRemote:FireServer("BlockPos", "Up")
  176. blockUpTrack:Play()
  177. shieldWeld.C0 = CFrame.new(shieldWeld.C0.Position) * CFrame.Angles(math.rad(90), math.rad(0), math.rad(0))
  178. shieldRotationRemote:FireServer(shieldWeld, "Shield", "Modified")
  179.  
  180. elseif not thurstUp then
  181. attributeRemote:FireServer("State", "Blocking")
  182. attributeRemote:FireServer("BlockPos", "Down")
  183. shieldWeld.C0 = CFrame.new(shieldWeld.C0.Position) * CFrame.Angles(math.rad(90), math.rad(0), math.rad(0))
  184. shieldRotationRemote:FireServer(shieldWeld, "Shield", "Modified")
  185. blockLowTrack:Play()
  186. end
  187. end
  188. end)
  189.  
  190. uis.InputEnded:Connect(function(input)
  191. if input.UserInputType == Enum.UserInputType.MouseButton2 then
  192. shieldWeld.C0 = CFrame.new(shieldWeld.C0.Position) * CFrame.Angles(math.rad(0), math.rad(0), math.rad(0))
  193. shieldRotationRemote:FireServer(shieldWeld, "Shield", "Original")
  194. blockUpTrack:Stop()
  195. blockLowTrack:Stop()
  196. if plr.Character:GetAttribute("State") == "Blocking" then
  197. attributeRemote:FireServer("State", "Default")
  198. end
  199. end
  200.  
  201. if input.UserInputType == Enum.UserInputType.MouseButton1 then
  202. if not isCharging then return end
  203. if debounce then return end
  204. if not isCharged then
  205. debounce = true
  206. gui.CanHit.ImageLabel.ImageColor3 = Color3.new(1, 0, 0)
  207. task.wait(0.27)
  208. task.delay(coolDownTime, EndCooldown)
  209. end
  210. if doubleDebounce then
  211. debounce = true
  212. gui.CanHit.ImageLabel.ImageColor3 = Color3.new(1, 0, 0)
  213. task.delay(coolDownTime, EndCooldown)
  214. end
  215. RemoveConnections()
  216. doubleDebounce = true
  217. isCharged = false
  218. isCharging = false
  219. thrustUpTrack:Stop()
  220. thrustLowTrack:Stop()
  221.  
  222. local sound = game.SoundService.SwordSwing:Clone()
  223. sound.Parent = char
  224. sound:Destroy()
  225.  
  226. if plr.Character:GetAttribute("State") == "Attacking" then
  227. if plr.Character:GetAttribute("AttackPos") == "Up" then
  228. thrustUpHitTrack:Play()
  229. thrustUpHitTrack:AdjustSpeed(0.5)
  230. animEnded = false
  231. local connect = thrustUpHitTrack.Stopped:Connect(function()
  232. task.wait(0.2)
  233. end)
  234. table.insert(connections, connect)
  235. remote:FireServer("Up", tool.Main)
  236. task.wait(0.03)
  237. elseif plr.Character:GetAttribute("AttackPos") == "Down" then
  238. thrustLowHitTrack:Play()
  239. thrustLowHitTrack:AdjustSpeed(0.5)
  240. animEnded = false
  241. remote:FireServer("Down", tool.Main)
  242. end
  243. end
  244.  
  245. if plr.Character:GetAttribute("State") == "Attacking" then
  246. attributeRemote:FireServer("State", "Default")
  247. end
  248. end
  249. end)
  250.  
  251. -- SERVER SCRIPT
  252. local remote = game.ReplicatedStorage.Remotes.GladiusRemote
  253. local swordRemote = game.ReplicatedStorage.Remotes.GladiusSwordRemote
  254. local ReplicatedStorage = game.ReplicatedStorage
  255. local RaycastHitbox = require(ReplicatedStorage.Modules.RaycastHitboxV4)
  256.  
  257. swordRemote.OnServerEvent:Connect(function(plr, item, transparency)
  258. item.Transparency = transparency
  259. end)
  260.  
  261. remote.OnServerEvent:Connect(function(plr, state, sword)
  262. if state == "Up" then
  263. local char = plr.Character
  264. local humrp = char.HumanoidRootPart
  265.  
  266. local hitbox = RaycastHitbox.new(sword)
  267. hitbox.Visualizer = true
  268.  
  269. hitbox.OnHit:Connect(function(hit, hum)
  270. if hum.Parent ~= char then
  271. if hum.Parent:GetAttribute("State") == "Blocking" then
  272. if hum.Parent:GetAttribute("BlockPos") == "Up" then
  273. local sound = game.SoundService.ShieldBlock:Clone()
  274. sound.Parent = hit
  275. sound:Destroy()
  276. return
  277. end
  278. end
  279. local sound = game.SoundService.SwordHit:Clone()
  280. sound.Parent = hit
  281. sound:Destroy()
  282. hum:TakeDamage(30)
  283. end
  284. end)
  285.  
  286. hitbox:HitStart()
  287. task.wait(0.4)
  288. hitbox:HitStop()
  289. elseif state == "Down" then
  290. local char = plr.Character
  291. local humrp = char.HumanoidRootPart
  292.  
  293. local hitbox = RaycastHitbox.new(sword)
  294. hitbox.Visualizer = true
  295.  
  296. hitbox.OnHit:Connect(function(hit, hum)
  297. if hum.Parent ~= char then
  298. if hum.Parent:GetAttribute("State") == "Blocking" then
  299. if hum.Parent:GetAttribute("BlockPos") == "Down" then
  300. local sound = game.SoundService.ShieldBlock:Clone()
  301. sound.Parent = hit
  302. sound:Destroy()
  303. return
  304. end
  305. end
  306. local sound = game.SoundService.SwordHit:Clone()
  307. sound.Parent = hit
  308. sound:Destroy()
  309. hum:TakeDamage(30)
  310. end
  311. end)
  312.  
  313. hitbox:HitStart()
  314. task.wait(0.4)
  315. hitbox:HitStop()
  316. end
  317. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement