Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- //interface variables
- local player = game:GetService("Players").LocalPlayer
- local character = player.Character
- local humanoid = character:WaitForChild("Humanoid")
- local animator = humanoid:WaitForChild("Animator") or humanoid:WaitForChild("AnimationController")
- local sprintHoldingWeapon = character:WaitForChild("Sprint"):WaitForChild("HoldingWeapon")
- local playerGui = player:WaitForChild("PlayerGui")
- local humRoot = character:WaitForChild("HumanoidRootPart")
- -- //services
- local userInput = game:GetService("UserInputService")
- local repStorage = game:GetService("ReplicatedStorage")
- local starterGui = game:GetService("StarterGui")
- local runService = game:GetService("RunService")
- -- //service folders
- local animationsFolder = script.Parent:WaitForChild("Animations")
- local soundsFolder = script.Parent:WaitForChild("Sounds")
- local eventsFolder = script.Parent:WaitForChild("Events")
- local hapticsFolder = script.Parent:WaitForChild("Haptics")
- local valuesFolder = script.Parent:WaitForChild("Values")
- -- //keyboard controls
- local defaultHeavyKeyboard = Enum.UserInputType.MouseButton2 -- MOUSE BUTTONS ONLY. TO CHANGE: // Enum.Keycode.{key}
- local defaultDodgeKeyboard = Enum.KeyCode.Q -- FOR DODGE CONTROL, YOU MUST ALSO CHANGE IN SPRINT SCRIPT: StarterPlayer\StarterCharacterScripts\Sprint
- local defaultSpecialKeyboard = Enum.KeyCode.R
- local defaultBlockKeyboard = Enum.KeyCode.F
- -- // //keyboard controls ui
- local keyboardControlsGroup = playerGui:WaitForChild("OtherButtons"):WaitForChild("KeyboardControls")
- local uikbDash = keyboardControlsGroup:WaitForChild("Dash")
- local uikbcbDash = keyboardControlsGroup:WaitForChild("CombatDash")
- local uikbEmotes = keyboardControlsGroup:WaitForChild("Emotes")
- local uikbcbAttack = keyboardControlsGroup:WaitForChild("CombatAttack")
- local uikbcbSpecial = keyboardControlsGroup:WaitForChild("CombatSpecialAtt")
- local uikbcbBlock = keyboardControlsGroup:WaitForChild("CombatBlock")
- local uikbcbHeavy = keyboardControlsGroup:WaitForChild("CombatHeavyAtt")
- local uikbSprint = keyboardControlsGroup:WaitForChild("Sprint")
- -- //gamepad controls
- local defaultHeavyGamepad = Enum.KeyCode.ButtonL2
- local defaultDodgeGamepad = Enum.KeyCode.ButtonL3 -- FOR DODGE CONTROL, YOU MUST ALSO CHANGE IN SPRINT SCRIPT: StarterPlayer\StarterCharacterScripts\Sprint
- local defaultSpecialGamepad = Enum.KeyCode.ButtonX
- local defaultBlockGamepad = Enum.KeyCode.ButtonB
- -- // //gamepad controls ui
- local gamepadControlsGroup = playerGui:WaitForChild("OtherButtons"):WaitForChild("GamepadControls")
- local uigpDash = gamepadControlsGroup:WaitForChild("Dash")
- local uigpcbDash = gamepadControlsGroup:WaitForChild("CombatDash")
- local uigpEmotes = gamepadControlsGroup:WaitForChild("Emotes")
- local uigpcbAttack = gamepadControlsGroup:WaitForChild("CombatAttack")
- local uigpcbSpecial = gamepadControlsGroup:WaitForChild("CombatSpecialAtt")
- local uigpcbBlock = gamepadControlsGroup:WaitForChild("CombatBlock")
- local uigpcbHeavy = gamepadControlsGroup:WaitForChild("CombatHeavyAtt")
- local uigpSprint = gamepadControlsGroup:WaitForChild("Sprint")
- -- //touch controls ui
- local touchControlsGroup = playerGui:WaitForChild("MobileButtons"):WaitForChild("MobileControls")
- local uitmcbHeavy = touchControlsGroup:WaitForChild("AttackHeavy")
- local uitmcbSprint = touchControlsGroup:WaitForChild("Sprint")
- local uitmEmotes = touchControlsGroup:WaitForChild("Emotes")
- local uitmcbSpecial = touchControlsGroup:WaitForChild("AttackSpecial")
- local uitmcbBlock = touchControlsGroup:WaitForChild("Block")
- -- //events
- local playerOpponentHit = eventsFolder:WaitForChild("PlayerOpponentHit")
- local playerBlockedAttack = eventsFolder:WaitForChild("PlayerBlockedAttack")
- local dialAttack = eventsFolder:WaitForChild("DialAttack")
- local dialAttackHeavy = eventsFolder:WaitForChild("DialHeavy")
- local dialAttackSpecial = eventsFolder:WaitForChild("DialSpecial")
- local beginBlocking = eventsFolder:WaitForChild("BeginBlocking")
- local endBlocking = eventsFolder:WaitForChild("EndBlocking")
- local dialDodge = eventsFolder:WaitForChild("DialDodge")
- local destroyBlockOpp = eventsFolder:WaitForChild("DestroyBlockOpp")
- local resetCombo = eventsFolder:WaitForChild("ResetCombo")
- local destroyBlockPlayer = eventsFolder:WaitForChild("DestroyBlockPlayer")
- -- //haptics
- local blockIncomiongAttackHaptic = hapticsFolder:WaitForChild("BlockHit")
- local blockBrokenHaptic = hapticsFolder:WaitForChild("BlockBroken")
- local damagedOpponentHaptic = hapticsFolder:WaitForChild("DamagedOpponent")
- local equipDuoHaptic = hapticsFolder:WaitForChild("EquipDuo")
- local attackAttemptHaptic = hapticsFolder:WaitForChild("AttackAttempt")
- local playerHit = hapticsFolder:WaitForChild("PlayerHit")
- -- //sounds
- local attackSound1 = soundsFolder:WaitForChild("Attack1")
- local attackSound2 = soundsFolder:WaitForChild("Attack2")
- local attackSound3 = soundsFolder:WaitForChild("Attack3")
- local attackSound4 = soundsFolder:WaitForChild("Attack4")
- local blockSound1 = soundsFolder:WaitForChild("Block1")
- local blockSound2 = soundsFolder:WaitForChild("Block2")
- local equipSound = soundsFolder:WaitForChild("Equip")
- local unequipSound = soundsFolder:WaitForChild("Unequip")
- local hitSound1 = soundsFolder:WaitForChild("Hit1")
- local hitSound2 = soundsFolder:WaitForChild("Hit2")
- local specialAttack = soundsFolder:WaitForChild("SpecialAttack")
- local specialHit = soundsFolder:WaitForChild("SpecialHit")
- -- //anim presets
- local attackPreset1 = animationsFolder:WaitForChild("Attack1")
- local attackPreset2 = animationsFolder:WaitForChild("Attack2")
- local attackPreset3 = animationsFolder:WaitForChild("Attack3")
- local blockPreset = animationsFolder:WaitForChild("Block")
- local dodgePreset = animationsFolder:WaitForChild("DodgeDash")
- local equipPreset = animationsFolder:WaitForChild("EquipDuo")
- local heavyAttackPreset1 = animationsFolder:WaitForChild("HeavyAttack1")
- local heavyAttackPreset2 = animationsFolder:WaitForChild("HeavyAttack2")
- local idlePreset = animationsFolder:WaitForChild("Idle")
- local specialAttackPreset = animationsFolder:WaitForChild("SpecialAttack")
- local unequipPreset = animationsFolder:WaitForChild("UnequipDuo")
- -- //animations
- local attackAnim = animator:LoadAnimation(attackPreset1)
- local attackAnim2 = animator:LoadAnimation(attackPreset2)
- local attackAnim3 = animator:LoadAnimation(attackPreset3)
- local blockAnim = animator:LoadAnimation(blockPreset)
- --local dodgeAnim = animator:LoadAnimation(dodgePreset)
- local equipAnim = animator:LoadAnimation(equipPreset)
- local heavyAttackAnim1 = animator:LoadAnimation(heavyAttackPreset1)
- local heavyAttackAnim2 = animator:LoadAnimation(heavyAttackPreset2)
- local idleAnim = animator:LoadAnimation(idlePreset)
- local specialAttackAnim = animator:LoadAnimation(specialAttackPreset)
- local unequipAnim = animator:LoadAnimation(unequipPreset)
- specialAttackAnim.Priority = Enum.AnimationPriority.Action4
- -- //values and variables
- -- // //cooldown variables
- local attackCooldown = valuesFolder:WaitForChild("AttackCooldown")
- local heavyCooldown = valuesFolder:WaitForChild("HeavyCooldown")
- local specialCooldown = valuesFolder:WaitForChild("SpecialCooldown")
- local blockCooldown = valuesFolder:WaitForChild("BlockCooldown")
- local blockBrokenShield = valuesFolder:WaitForChild("BlockBrokenCooldown")
- local dodgeSyncCooldown = valuesFolder:WaitForChild("DodgeDashCooldown")
- local blockPower = valuesFolder:WaitForChild("BlockPower")
- local maxBlockPower = valuesFolder:WaitForChild("MaxBlockPower")
- -- // //attack variables
- local canAttack = true
- local canDodge = true
- local canDuck = true
- local canSpecial = true
- local canBlock = true
- -- // //defense variables
- local isBlocking = false
- local isDodging = false
- local isAttacking = false
- local toolEquipped = false
- local currentAttack = 1
- script.Parent.Activated:Connect(function()
- if canAttack and not isBlocking and not isDodging then
- canAttack = false
- dialAttack:FireServer()
- if currentAttack == 1 then
- attackAnim:Play()
- attackSound1:Play()
- currentAttack = 2
- elseif currentAttack == 2 then
- attackAnim2:Play()
- attackSound2:Play()
- currentAttack = 3
- elseif currentAttack == 3 then
- attackAnim3:Play()
- attackSound3:Play()
- currentAttack = 1
- end
- attackAttemptHaptic:Play()
- task.wait(attackCooldown.Value)
- canAttack = true
- else
- return false;
- end
- end)
- script.Parent.Equipped:Connect(function()
- toolEquipped = true
- equipSound:Play()
- equipAnim:Play()
- idleAnim:Play()
- sprintHoldingWeapon.Value = true
- sprintHoldingWeapon.Parent:WaitForChild("SGearDashCooldown").Value = dodgeSyncCooldown.Value
- uikbDash.Visible = false
- uikbcbDash.Visible = true
- uikbEmotes.Visible = false
- uikbcbAttack.Visible = true
- uikbcbSpecial.Visible = true
- uikbcbBlock.Visible = true
- uikbcbHeavy.Visible = true
- uikbSprint.Visible = false
- uigpDash.Visible = false
- uigpcbDash.Visible = true
- uigpEmotes.Visible = false
- uigpcbAttack.Visible = true
- uigpcbSpecial.Visible = true
- uigpcbBlock.Visible = true
- uigpcbHeavy.Visible = true
- uigpSprint.Visible = false
- uitmcbHeavy.Visible = true
- uitmcbSprint.Image = "rbxassetid://83841678364163"
- uitmEmotes.Visible = false
- uitmcbSpecial.Visible = true
- uitmcbBlock.Visible = true
- end)
- script.Parent.Unequipped:Connect(function()
- unequipSound:Play()
- idleAnim:Stop()
- unequipAnim:Play()
- toolEquipped = false
- sprintHoldingWeapon.Value = false
- sprintHoldingWeapon.Parent:WaitForChild("SGearDashCooldown").Value = 0
- uikbDash.Visible = true
- uikbcbDash.Visible = false
- uikbEmotes.Visible = true
- uikbcbAttack.Visible = false
- uikbcbSpecial.Visible = false
- uikbcbBlock.Visible = false
- uikbcbHeavy.Visible = false
- uikbSprint.Visible = true
- uigpDash.Visible = true
- uigpcbDash.Visible = false
- uigpEmotes.Visible = true
- uigpcbAttack.Visible = false
- uigpcbSpecial.Visible = false
- uigpcbBlock.Visible = false
- uigpcbHeavy.Visible = false
- uigpSprint.Visible = true
- uitmcbHeavy.Visible = false
- uitmcbSprint.Image = "rbxassetid://73337704931687"
- uitmEmotes.Visible = true
- uitmcbSpecial.Visible = false
- uitmcbBlock.Visible = false
- end)
- function blockFunction() --block
- if canBlock then
- blockAnim:Play()
- beginBlocking:FireServer()
- isBlocking = true
- canBlock = false
- else
- return false;
- end
- end
- function specialAttack() --special
- if canSpecial and not isDodging and not isBlocking then
- specialAttackAnim:Play()
- dialAttackSpecial:FireServer()
- destroyBlockOpp:FireServer()
- canSpecial = false
- task.wait(specialCooldown.Value)
- canSpecial = true
- else
- return false;
- end
- end
- local currentHeavyAttack = 1
- function heavyAttack()
- if canAttack and not isDodging and not isBlocking then
- canAttack = false
- humanoid.WalkSpeed = 0
- sprintHoldingWeapon.Parent:WaitForChild("HeavyAttacking").Value = true
- dialAttackHeavy:FireServer()
- uitmcbHeavy.Visible = false
- if currentHeavyAttack == 1 then
- heavyAttackAnim1:Play()
- currentHeavyAttack = 2
- else
- heavyAttackAnim2:Play()
- currentHeavyAttack = 1
- end
- task.wait(heavyCooldown.Value)
- uitmcbHeavy.Visible = true
- humanoid.WalkSpeed = 6
- canAttack = true
- sprintHoldingWeapon.Parent:WaitForChild("HeavyAttacking").Value = false
- else
- script.Parent:Activate()
- end
- end
- function dodgeRequest()
- if canDodge then
- canDodge = false
- dialDodge:FireServer()
- task.wait(dodgeSyncCooldown.Value)
- else
- return false;
- end
- end
- function endBlockFunction() --block
- if isBlocking then
- blockAnim:Stop()
- endBlocking:FireServer()
- isBlocking = false
- task.wait(blockCooldown.Value)
- canBlock = true
- end
- end
- function playerBlockBroken() --special attack recieved and is blocking
- if canBlock or isBlocking then
- blockAnim:Stop()
- endBlocking:FireServer()
- isBlocking = false
- canBlock = false
- wait(blockBrokenShield.Value)
- canBlock = true
- else
- return false;
- end
- end
- userInput.InputBegan:Connect(function(input)
- if toolEquipped then
- if input.KeyCode == defaultBlockKeyboard or input.KeyCode == defaultBlockGamepad then --block
- blockFunction()
- elseif input.KeyCode == defaultSpecialKeyboard or input.KeyCode == defaultSpecialGamepad then --special
- specialAttack()
- elseif input.KeyCode == defaultDodgeKeyboard or input.KeyCode == defaultSpecialGamepad then --ready dodge
- dodgeRequest()
- elseif input.UserInputType == defaultHeavyKeyboard or input.KeyCode == defaultHeavyGamepad then --heavy attack
- heavyAttack()
- end
- else
- return false;
- end
- end)
- userInput.InputEnded:Connect(function(input)
- if toolEquipped then
- if input.KeyCode == defaultBlockKeyboard or input.KeyCode == defaultBlockGamepad then --block
- endBlockFunction()
- elseif input.KeyCode == defaultSpecialKeyboard or input.KeyCode == defaultSpecialGamepad then --special
- specialAttack()
- elseif input.KeyCode == defaultDodgeKeyboard or input.KeyCode == defaultDodgeGamepad then --ready dodge
- print("tool dodge specification ended")
- elseif input.UserInputType == defaultHeavyKeyboard or input.KeyCode == defaultHeavyGamepad then --heavy attack
- print("heavy attack ended")
- end
- else
- return false;
- end
- end)
- uitmcbHeavy.Activated:Connect(function()
- heavyAttack()
- end)
- uitmcbSpecial.Activated:Connect(function()
- specialAttack()
- end)
- uitmcbBlock.Activated:Connect(function()
- if not isBlocking then
- blockFunction()
- else
- endBlockFunction()
- end
- end)
- local wasBroken = valuesFolder:WaitForChild("BlockWasBroken").Value
- while task.wait(0.1) do
- if blockPower.Value <= 0 and not wasBroken then
- blockPower.Value = 0
- playerBlockBroken()
- wasBroken = true
- elseif blockPower.Value > 0 and wasBroken then
- -- Reset once the block starts regenerating
- wasBroken = false
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement