Advertisement
Ultimate_69

HiddenDevs Script

Mar 21st, 2024
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 11.90 KB | None | 0 0
  1. -- Explanation: This ServerScript runs through a local script inserted into a tool named "Combat.", which fires off a remote event that triggers said server script. The local script itself has 3 values it may pass on when firing the remote event, which are either: "Normal", which is any attack with a comboCount less than 4, and "Final" which is any attack with a comboCount >= 4, and "Black Flash" which is a 1 in 40 chance of a special attack. There will be a provided tool named "Black Flash" which will have it occur on every use. Now here is the serverscript, which is approximately 223 lines of code.
  2. -- Blocking Explanation: Before we get into the serverscript, there is a seperate local script that is placed into startercharacter scripts, where if the player presses "F" (or a button on mobile), they will fire off a remote event to change a boolValue also in startercharacterscripts to true. Now here is the serverscript.
  3. -- // Remote Event Declaration \\
  4. local remote = game.ReplicatedStorage.Remotes.CombatRemote
  5. remote.OnServerEvent:Connect(function(plr, state) -- state is what the LocalScript passed on, which could either be a block, or a combo type.
  6.        
  7.         -- // Variables \\
  8.        
  9.     local char = plr.Character
  10.     local hum = char:WaitForChild("Humanoid")
  11.     local humrp = char:WaitForChild("HumanoidRootPart")
  12.        
  13.         -- // Blocking Remotes \\
  14.    
  15.     if state == "BlockStart" then
  16.         char:WaitForChild("Blocking").Value = true -- sets Blocking boolValue to true
  17.     end
  18.    
  19.     if state == "BlockEnd" then
  20.         char:WaitForChild("Blocking").Value = false -- sets Blocking boolValue to false
  21.     end
  22.        
  23.         -- // Normal Combo \\
  24.    
  25.     if state == "Normal" then
  26.            
  27.  -- Hitbox creation with it's properties, and moving it infront of the player using CFrames.
  28.         local hitbox = Instance.new("Part", workspace)
  29.         hitbox.CFrame = humrp.CFrame * CFrame.new(0, 0, -2.5)
  30.         hitbox.Size = Vector3.new(5, 5, 5)
  31.         hitbox.Transparency = 0.5
  32.         hitbox.BrickColor = BrickColor.Green()
  33.         hitbox.CanCollide = false
  34.         hitbox.Anchored = false
  35.         game.Debris:AddItem(hitbox, 0.35)
  36.            
  37.   -- Welding the Hitbox to the player, since if it is anchored, it will lead to inaccurate Combat
  38.        
  39.         local weld = Instance.new("WeldConstraint")
  40.         weld.Parent = hitbox
  41.         weld.Part0 = humrp
  42.         weld.Part1 = hitbox
  43.            
  44.    -- Handles the removal of the hitbox after enough time passes using Debris Service.
  45.        
  46.         game.Debris:AddItem(weld, 0.35)
  47.        
  48.         local Hits = {} -- Table of everything hit, used in the hitbox.Touched event to ensure noone gets damaged twice.
  49.        
  50.       -- // Hitbox Touched \\      
  51.            
  52.         hitbox.Touched:Connect(function(hit)
  53.             if hit.Parent:FindFirstChild("Humanoid") then -- Checking if the parent of the hit is a Humanoid
  54.                 if hit.Name == "HumanoidRootPart" then -- Checking if the hit part is a HumanoidRootPart
  55.                     if hit.Parent.Name ~= char.Name then -- Ensuring the hit part is not the player
  56.                         if Hits[hit.Parent.Name] then
  57.                             return
  58.                         end -- If the target has already been hit once, then this will return.
  59.                        
  60.                         if hit.Parent:FindFirstChild("Blocking").Value == true then
  61.                             local hitSfx = game.SoundService.Block:Clone()
  62.                             hitSfx.Parent = hit.Parent
  63.                             hitSfx:Play()
  64.                             game.Debris:AddItem(hitSfx, 0.4)
  65.                             return
  66.                         end -- If it's true, then the next portion of the script is negated due to this if statement returning, it also plays a block sound effect.
  67.                        
  68.                         Hits[hit.Parent.Name] = true
  69.                         local ehum = hit.Parent:WaitForChild("Humanoid")
  70.                         ehum:TakeDamage(3) -- Damages the player and sets their damaged status to true.
  71.                        
  72.                         local track = game.SoundService.Hit:Clone()
  73.                         track.Parent = hit.Parent
  74.                         track:Play()
  75.                         game.Debris:AddItem(track, 0.7)
  76.                                 -- Plays hit sfx
  77.                        
  78.                         wait(0.2)
  79.                         local anim = ehum:LoadAnimation(game.ReplicatedStorage.Animations.Combat.Hit)
  80.                         anim:Play()
  81.                         Hits[hit.Parent.Name] = false -- Plays animation of player getting hit, and disables the hit status of the target.
  82.                     end
  83.                 end
  84.             end
  85.         end)
  86.     end
  87.        
  88.         -- // Final Hit in a Comboo \\
  89.    
  90.     if state == "Final" then
  91.         local hitbox = Instance.new("Part", workspace)
  92.         hitbox.CFrame = humrp.CFrame * CFrame.new(0, 0, -2.5)
  93.         hitbox.Size = Vector3.new(5, 5, 5)
  94.         hitbox.Transparency = 0.5
  95.         hitbox.BrickColor = BrickColor.Red()
  96.         hitbox.CanCollide = false
  97.         hitbox.Anchored = false
  98.         game.Debris:AddItem(hitbox, 0.35)
  99.         local weld = Instance.new("WeldConstraint")
  100.         weld.Parent = hitbox
  101.         weld.Part0 = humrp
  102.         weld.Part1 = hitbox
  103.         game.Debris:AddItem(weld, 0.35)
  104.        
  105.         local Hits = {}
  106.         hitbox.Touched:Connect(function(hit)
  107.             if hit.Parent:FindFirstChild("Humanoid") then
  108.                 if hit.Name == "HumanoidRootPart" then
  109.                     if hit.Parent.Name ~= char.Name then
  110.                         if Hits[hit.Parent.Name] then
  111.                             return
  112.                         end
  113.                         if hit.Parent:WaitForChild("Blocking").Value == true then
  114.                             local hitSfx = game.SoundService.BlockBreak:Clone()
  115.                             local ehum = hit.Parent:WaitForChild("Humanoid")
  116.                             hitSfx.Parent = hit.Parent
  117.                             hitSfx:Play()
  118.                             game.Debris:AddItem(hitSfx, 0.4)
  119.                             hit.Parent:WaitForChild("Stunned").Value = true
  120.                             ehum.WalkSpeed = 0
  121.                         end -- This time, however, rather than return, the script instead plays the sfx of breaking the block, and stuns the enemy,
  122.                         Hits[hit.Parent.Name] = true
  123.                         local ehum = hit.Parent:WaitForChild("Humanoid")
  124.                         local ehumrp = hit.Parent:WaitForChild("HumanoidRootPart")
  125.                         ehum:TakeDamage(6) -- More damage on final hit
  126.                        
  127.                         local bv = Instance.new("BodyVelocity", ehumrp)
  128.                         bv.MaxForce = Vector3.one * math.huge
  129.                         bv.Velocity = char.HumanoidRootPart.CFrame.LookVector * 35 + Vector3.new(0, 45, 0)
  130.                         game.Debris:AddItem(bv, 0.12) -- Uses body velocity to knockback the target
  131.                         local track = game.SoundService.HitCrit:Clone()
  132.                         track.Parent = hit.Parent
  133.                         track:Play()
  134.                         game.Debris:AddItem(track, 0.7)
  135.                         wait(0.2)
  136.                         local anim = ehum:LoadAnimation(game.ReplicatedStorage.Animations.Combat.Knockback)
  137.                         anim:Play()
  138.                         ehum.WalkSpeed = 16
  139.                         hit.Parent:WaitForChild("Stunned").Value = false
  140.                         Hits[hit.Parent.Name] = false -- Unstuns the opponent, and plays a knockback animation.
  141.                     end
  142.                 end
  143.             end
  144.         end)
  145.     end
  146.        
  147.        
  148.      -- // Black Flash (1 in 40 chance) \\
  149.        
  150.     if state == "BlackFlash" then
  151.        
  152.         print("Black Flash!")
  153.        
  154.         local bf = game.ReplicatedStorage.Models.HandFlash:Clone()
  155.         bf.Anchored = false
  156.         bf.Parent = char
  157.         bf.CFrame = humrp.CFrame
  158.         game.Debris:AddItem(bf, 2)
  159.         local weld2 = Instance.new("WeldConstraint")
  160.         weld2.Parent = bf
  161.         weld2.Part0 = humrp
  162.         weld2.Part1 = bf
  163.            
  164.         -- Welds the BlackFlash model intended to be used for the char to the char's root part.
  165.            
  166.            
  167.         game.Debris:AddItem(weld2, 2)
  168.        
  169.         local hitbox = Instance.new("Part", workspace)
  170.         hitbox.CFrame = humrp.CFrame * CFrame.new(0, 0, -2.5)
  171.         hitbox.Size = Vector3.new(5, 5, 5)
  172.         hitbox.Transparency = 0.5
  173.         hitbox.BrickColor = BrickColor.Black()
  174.         hitbox.CanCollide = false
  175.         hitbox.Anchored = false
  176.         game.Debris:AddItem(hitbox, 0.35)
  177.         local weld = Instance.new("WeldConstraint")
  178.         weld.Parent = hitbox
  179.         weld.Part0 = humrp
  180.         weld.Part1 = hitbox
  181.         game.Debris:AddItem(weld, 0.35)
  182.        
  183.         local Hits = {}
  184.         hitbox.Touched:Connect(function(hit)
  185.             if hit.Parent:FindFirstChild("Humanoid") then
  186.                 if hit.Name == "HumanoidRootPart" then
  187.                     if hit.Parent.Name ~= char.Name then
  188.                         if Hits[hit.Parent.Name] then
  189.                             return
  190.                         end
  191.                         if hit.Parent:WaitForChild("Blocking").Value == true then
  192.                             local hitSfx = game.SoundService.BlockBreak:Clone()
  193.                             local ehum = hit.Parent:WaitForChild("Humanoid")
  194.                             hitSfx.Parent = hit.Parent
  195.                             hitSfx:Play()
  196.                             game.Debris:AddItem(hitSfx, 0.4)
  197.                             hit.Parent:WaitForChild("Stunned").Value = true
  198.                             ehum.WalkSpeed = 0
  199.                         end
  200.                         Hits[hit.Parent.Name] = true
  201.                         local ehum = hit.Parent:WaitForChild("Humanoid")
  202.                         local ehumrp = hit.Parent:WaitForChild("HumanoidRootPart")
  203.                         ehum:TakeDamage(9) -- Increased damage here a swell.
  204.                        
  205.                         local bf = game.ReplicatedStorage.Models.BlackFlash:Clone()
  206.                         bf.Anchored = false
  207.                         bf.Parent = hit.Parent
  208.                         bf.CFrame = ehumrp.CFrame
  209.                         game.Debris:AddItem(bf, 2)
  210.                         local weld2 = Instance.new("WeldConstraint")
  211.                         weld2.Parent = bf
  212.                         weld2.Part0 = ehumrp
  213.                         weld2.Part1 = bf
  214.                                
  215.                                 -- Welds the BlackFlash model intended to be added to the opponent
  216.                        
  217.                         game.Debris:AddItem(weld2, 2)
  218.                         local bv = Instance.new("BodyVelocity", ehumrp)
  219.                         bv.MaxForce = Vector3.one * math.huge
  220.                         bv.Velocity = char.HumanoidRootPart.CFrame.LookVector * 35 + Vector3.new(0, 45, 0)
  221.                         game.Debris:AddItem(bv, 0.12)
  222.                         local track = game.SoundService.HitCrit:Clone()
  223.                         track.Parent = hit.Parent
  224.                         track:Play()
  225.                         game.Debris:AddItem(track, 0.7)
  226.                         wait(0.2)
  227.                         ehum.WalkSpeed = 16
  228.                         hit.Parent:WaitForChild("Stunned").Value = false
  229.                         local anim = ehum:LoadAnimation(game.ReplicatedStorage.Animations.Combat.Knockback)
  230.                         anim:Play()
  231.                         Hits[hit.Parent.Name] = false
  232.                     end
  233.                 end
  234.             end
  235.         end)
  236.     end
  237. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement