I’ve been looking around forums for a bit and I still have no idea on how to fix this.
-- Variables
local M1Function = script:WaitForChild("M1")
local UIS = game:GetService("UserInputService")
local rs = game:GetService("ReplicatedStorage")
local rsAnimationsFolder = rs:WaitForChild("Fists")
-- Player & Services
local players = game:GetService("Players")
local LPlayers = players.LocalPlayer
local char = LPlayers.Character or LPlayers.CharacterAppearanceLoaded:Wait()
local hum = char:WaitForChild("Humanoid")
local animator = hum:WaitForChild("Animator")
-- M1s & Cooldowns
local M1sPerformed = 0
local currentM1 = 0
local m1Debounce = false
local FistsEquipped = false
local comboEndCooldown = 2
local waitBeforeReset = 0.5
-- Equip & Unequip
local function OnInputBegan(InputObject, GameProcessed)
if GameProcessed then return end
if InputObject.KeyCode.Name == "E" then -- and FistsEquipped == false
local EquipAnim = rsAnimationsFolder:FindFirstChild("Equip")
local IdleAnim = rsAnimationsFolder:FindFirstChild("Idle")
EquipAnim.Priority = Enum.AnimationPriority.Action
EquipAnim:Play()
FistsEquipped = true
print ("Fists are equipped")
end
if InputObject == "E" and FistsEquipped == true then
-- Change IdleAnim back to normal when unequipped
local UnequipAnim = rsAnimationsFolder:FindFirstChild("Unequip")
UnequipAnim.Priority = Enum.AnimationPriority.Action
UnequipAnim:Play()
FistsEquipped = false
print ("Fists are unequipped")
end
end
It’s a part of a local script I’ll just send it, hold on. Yes I wrote it.
-- Variables
local M1Function = script:WaitForChild("M1")
local UIS = game:GetService("UserInputService")
local rs = game:GetService("ReplicatedStorage")
local FistAnimFolder = rs.Storage.Animations["M1's"]
local rsAnimationsFolder = FistAnimFolder:WaitForChild("Fists")
-- Player & Services
local players = game:GetService("Players")
local LPlayers = players.LocalPlayer
local char = LPlayers.Character or LPlayers.CharacterAppearanceLoaded:Wait()
local hum = char:WaitForChild("Humanoid")
local animator = hum:WaitForChild("Animator")
local HumRP = char:WaitForChild("HumanoidRootPart")
-- M1s & Cooldowns
local M1sPerformed = 0
local currentM1 = 0
local m1Debounce = false
local FistsEquipped = true
local comboEndCooldown = 2
local waitBeforeReset = 0.5
-- Equip & Unequip
UIS.InputBegan:Connect(function(Input, GPE)
if GPE then return end
if Input.KeyCode == Enum.KeyCode.E and not FistsEquipped then
local EquipAnim = rsAnimationsFolder:FindFirstChild("Equip")
local IdleAnim = rsAnimationsFolder:FindFirstChild("Idle")
EquipAnim.Priority = Enum.AnimationPriority.Action
EquipAnim:Play()
FistsEquipped = true
print ("Fists are equipped")
end
if Input.KeyCode == Enum.KeyCode.E and FistsEquipped then
-- Change IdleAnim back to normal when unequipped
local UnequipAnim = rsAnimationsFolder:FindFirstChild("Unequip")
UnequipAnim.Priority = Enum.AnimationPriority.Action
UnequipAnim:Play()
FistsEquipped = false
print ("Fists are unequipped")
end
end)
-- Main Scripting
M1Function.OnInvoke = function ()
if not m1Debounce then
m1Debounce = true
M1sPerformed += 1
currentM1 += 1
local correspondingM1anim = rsAnimationsFolder:FindFirstChild("M1 ("..currentM1..")")
local M1Track = animator:LoadAnimation(correspondingM1anim)
M1Track:Play()
M1Track:GetMarkerReachedSignal('Hit'):Connect(function(Parameter)
print ("Hitbox made.")
local hitbox = Instance.new ('Part')
hitbox.Size = Vector3.new (6 ,6 , 5)
hitbox.Transparency = 0.8
hitbox.CanCollide = false
hitbox.Massless= true
hitbox.Anchored = false
hitbox.Color = Color3.new (1, 0, 0.0156863)
hitbox.CFrame = HumRP.CFrame * CFrame.new (0, 0, ((hitbox.Size.Z/2) + 0.5) * -1)
hitbox.Parent = workspace["Hitboxes/Effects"]
local hitboxWeld = Instance.new('WeldConstraint')
hitboxWeld.Part0 = HumRP
hitboxWeld.Part1 = HumRP
hitboxWeld.Parent = hitbox
local partsInsideHitbox = workspace:GetPartsInPart(hitbox)
local function hitboxFunction(v)
if v.Parent:FindFirstChild("Humanoid") and v.Parent.Name ~= char.Name then
local enemyHum = v.Parent:FindFirstChild("Humanoid")
enemyHum:TakeDamage(10)
enemyHum.WalkSpeed = 8
print (enemyHum.Health)
print("Enemy Has taken Damage")
end
if currentM1 == 3 then
if v.Parent:FindFirstChild("Humanoid") and v.Parent.Name ~= char.Name then
local enemyHum = v.Parent:FindFirstChild("Humanoid")
local bv = Instance.new("BodyVelocity")
local offset = Vector3.new()
bv.Parent = (enemyHum.LowerTorso)
bv.MaxForce = Vector3.new(100000,100000,100000) -- can mess with this or the 80's
bv.Velocity = (enemyHum.Head.CFrame.LookVector * -80)
+ (enemyHum.Head.CFrame.UpVector * 80)
print ("Knock Back Made")
wait(0.01) bv:Destroy()
enemyHum.WalkSpeed = 16
end task.wait (.33)
end
hitboxFunction(v)
print ('Touched'..v.Parent.Name)
end
hitbox:Destroy()
end)
hum.WalkSpeed = 12
print ("M1 Preformed")
task.wait(M1Track.Length - 0.1 )
hum.WalkSpeed = 16
task.spawn(function()
local oldM1sPerformed = M1sPerformed
task.wait (waitBeforeReset)
if oldM1sPerformed == M1sPerformed then
currentM1 = 0 -- Resets m1 combo
end
end)
if currentM1 == 4 then
task.wait(comboEndCooldown)
currentM1 = 0 -- Resets m1 combo
end
m1Debounce = false
end
end
-- Critical Functions
local CriticalDebounce = false
local CriticalCD = 4
UIS.InputBegan:Connect(function(Input,GPE)
if GPE then return end
if Input.KeyCode == Enum.KeyCode.R then
if FistsEquipped == true then
if not CriticalDebounce then
CriticalDebounce = true
local CriticalAnim = rsAnimationsFolder:FindFirstChild("Critical")
CriticalAnim:Play()
hum.WalkSpeed = 10
print ("Using Critical")
CriticalAnim:GetMarkerReachedSignal('Hit', 'Hit2', 'Hit3'):Connect(function(param)
local hitbox = Instance.new ('Part')
hitbox.Size = Vector3.new (6 ,6 , 5)
hitbox.Transparency = 0.8
hitbox.CanCollide = false
hitbox.Massless= true
hitbox.Anchored = false
hitbox.Color = Color3.new (1, 0, 0.0156863)
hitbox.CFrame = HumRP.CFrame * CFrame.new (0, 0, ((hitbox.Size.Z/2) + 0.5) * -1)
hitbox.Parent = workspace["Hitboxes/Effects"]
local hitboxWeld = Instance.new('WeldConstraint')
hitboxWeld.Part0 = HumRP
hitboxWeld.Part1 = HumRP
hitboxWeld.Parent = hitbox
local partsInsideHitbox = workspace:GetPartsInPart(hitbox)
local function hitboxFunction(v)
if v.Parent:FindFirstChild("Humanoid") and v.Parent.Name ~= char.Name then
local enemyHum = v.Parent:FindFirstChild("Humanoid")
enemyHum:TakeDamage(10)
print (enemyHum.Health)
end
CriticalAnim:GetMarkerReachedSignal('Hit3'):Connect(function()
-- Knockback Module
end)
print ('Touched'..v.Parent.Name)
end
hitbox:Destroy()
end)
end
end
hum.WalkSpeed = 16
task.wait (CriticalCD)
CriticalDebounce = false
end
end)
-- Block
local blockDebounce = false
UIS.InputBegan:Connect(function(Input,GPE)
if GPE then return end
if Input.KeyCode == Enum.KeyCode.F then
if FistsEquipped == true then
if blockDebounce then
local blockDebounce = true
local Blocking = true
local BlockAnim = rsAnimationsFolder:FindFirstChild("Block")
BlockAnim:Play()
hum.WalkSpeed = 8
hum.JumpPower = 0
print ("Blocking")
end
end
end
end)
I fixed the Equip anim. I forgot I didn’t have a unequip animation so the second If statement didn’t even run. I swapped the lines EquipAnim to this after a bit of debugging
So, i think the problem is that the fists are equipping and unequipping at the same time. So your solution should be putting a return in the first if statement here. You can also make the second if statement an elseif instead if you want to do that.
if Input.KeyCode == Enum.KeyCode.E and not FistsEquipped then
--> it equips first as intended
local EquipAnim = rsAnimationsFolder:FindFirstChild("Equip")
local IdleAnim = rsAnimationsFolder:FindFirstChild("Idle")
EquipAnim.Priority = Enum.AnimationPriority.Action
EquipAnim:Play()
FistsEquipped = true
print ("Fists are equipped")
return --> we put a return here because the conditions for the second if statement to unequip is met, and we don't want that
end
if Input.KeyCode == Enum.KeyCode.E and FistsEquipped then
--> now only unequips after you input while fists are equipped
local UnequipAnim = rsAnimationsFolder:FindFirstChild("Unequip") --> i think you fixed this line not finding the animation?
UnequipAnim.Priority = Enum.AnimationPriority.Action
UnequipAnim:Play()
FistsEquipped = false
print ("Fists are unequipped")
end
I didn’t test this though so let me know if it works