Trying to learn more about OOP and metatables and started running into issues I don’t understand.
My output window shows that the initial setup fires twice?
I have print functions set to test when debounce gets set back to false allowing another attack to go through. Whenever a combo resets back to 1, the debounce print fires equal to how many rotations have passed?
This is all currently clientsided
local script
local Auxillary = require(game:GetService("ReplicatedStorage").Modules.Auxillary.Auxillary)
local Services = Auxillary.Services
local Player = Services.p.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local testRequire = require(game:GetService("ReplicatedStorage").Modules.CombatSystem.Sword.Skillset)
Humanoid:SetStateEnabled(Enum.HumanoidStateType.FallingDown, false)
local Setup = testRequire.Setup(Player)
function InputHandler(ActionName, InputState, InputObject)
if ActionName == "Attack" then
if InputState == Enum.UserInputState.Begin then
Setup:Attack()
end
end
return Enum.ContextActionResult.Pass
end
Services.cas:BindAction("Attack", InputHandler, true, Enum.UserInputType.MouseButton1, Enum.KeyCode.ButtonA)
module script
function SwordSkillset:Attack()
if self.Debounce then return end
self.Debounce = true
local Character = self.User.Character
-- If on ground, play animation.
if Character.Humanoid.FloorMaterial ~= Enum.Material.Air then
self.Animations["Attack_Ground_".. self.Combo]:Play(0)
self.Animations["Attack_Ground_".. self.Combo].Stopped:Connect(function()
if not self.Debounce then return end
self.Debounce = false
print("debounce false")
end)
end
-- Testing for now. When working, this will only fire when the attack connects with an enemy
if self.Debounce then
-- If attack is not a flourish and your attack hits the enemy, cancel debounce early.
if not Services.cs:HasTag(Assets.Animations["Attack_Ground_".. self.Combo], "Flourish") then
--
self.Animations["Attack_Ground_".. self.Combo]:GetMarkerReachedSignal("DebounceEnd"):Connect(function()
self.Debounce = false
print("debounce false")
end)
end
end
-- Increase combo by 1. If flourish, reset combo.
if self.Combo == 3 then
print("combo complete, reset back to 1")
self.Combo = 1
else
self.Combo += 1
end
end