Studio:
https://gyazo.com/7528cabfd413a725717402c15a5ee8a8
In-Game:
https://gyazo.com/79d4a1f7dafaeb8c11840e10a5912d18
Main Weapon Logic:
local connection_bin_module = require(script.ConnectionBin.Value)
local signal = require(script.Signal.Value)
local client_cast_module = require(script.ClientCast)
local damage_module = require(script.Damage)
local combo_module = require(script.Combo)
export type Weapon = {
hitbox_owner : Player?,
humanoid_root_part : BasePart,
action_event : RBXScriptSignal,
hitbox_part : BasePart,
raycast_params : RaycastParams,
max_combo : number,
max_combo_time : number,
delay_callback : (combo:number) -> (number),
attack_duration_callback : (combo:number) -> (number),
damage_callback : (combo:number) -> (number),
knockback_callback : (combo:number) -> ({force:number, duration:number}),
max_health : {
["Right Arm"]: number,
["Right Leg"]: number,
["Left Arm"]: number,
["Left Leg"]: number,
["Torso"]: number,
["Head"]: number
},
limb_health_name : string,
_on_action : RBXScriptSignal,
_on_hit : RBXScriptSignal,
_connection_bin : connection_bin_module.ConnectionBin,
_client_caster : client_cast_module.ClientCast,
_hit_debounce : {Humanoid},
_damage : damage_module.Damage,
_action_tick : number,
_combo : combo_module.Combo,
_activated_debounce : boolean
}
local weapon = {}
local function on_activated(self : Weapon)
if self._activated_debounce then return end
self._activated_debounce = true
local curr_combo = combo_module.next(self._combo)
self._on_action:Fire(curr_combo)
self._action_tick = tick()
task.delay(self.delay_callback(curr_combo), function()
self._client_caster:Start()
end)
local attack_duration = self.attack_duration_callback(curr_combo) or 0
task.delay(attack_duration, function()
self._activated_debounce = false
self._client_caster:Stop()
end)
end
local function knockback(self : Weapon, target_root)
local knockback_data = self.knockback_callback(combo_module.current(self._combo))
local direction = (target_root.Position - self.humanoid_root_part.Position).Unit
local rot_direction = (target_root.Orientation - self.humanoid_root_part.Orientation).Unit
local body_velocity = Instance.new("BodyVelocity", target_root)
local old_owner = target_root:GetNetworkOwner()
target_root:SetNetworkOwner(self.hitbox_owner)
task.delay(knockback_data.duration*2, function()
if target_root.Parent ~= workspace then return end
target_root:SetNetworkOwner(old_owner)
end)
body_velocity.MaxForce = Vector3.one * math.huge
body_velocity.Velocity = direction * knockback_data.force
game.Debris:AddItem(body_velocity, knockback_data.duration)
local body_angular_velocity = Instance.new("BodyAngularVelocity", target_root)
body_angular_velocity.AngularVelocity = rot_direction * math.pi * 2.5
body_angular_velocity.MaxTorque = Vector3.one * math.huge
body_angular_velocity.P = knockback_data.force
game.Debris:AddItem(body_angular_velocity, knockback_data.duration)
end
local function on_hit(self : Weapon, raycast_result, humanoid)
if self._hit_debounce[humanoid] then return end
self._hit_debounce[humanoid] = true
local curr_combo = combo_module.current(self._combo)
local debounce_time = self.attack_duration_callback(curr_combo) - (tick() - self._action_tick)
task.delay(debounce_time, function()
self._hit_debounce[humanoid] = nil
end)
humanoid:TakeDamage(10)
self._on_hit:Fire(damage_module.damage(self._damage, raycast_result.Instance, self.damage_callback(curr_combo)), raycast_result, humanoid)
knockback(self, humanoid.Parent.HumanoidRootPart)
end
function weapon.init(self : Weapon)
self._connection_bin = {}
connection_bin_module.init(self._connection_bin)
self._client_caster = client_cast_module.new(self.hitbox_part, self.raycast_params)
self._client_caster:SetOwner(self.hitbox_owner)
self._on_action = signal.new()
self._on_hit = signal.new()
self._damage = {
damages = self.damages,
max_health = self.max_health,
limb_health_name = self.limb_health_name
}
self._hit_debounce = {}
self._action_tick = math.huge
self._combo = {
max_combo = self.max_combo,
max_time = self.max_combo_time,
}
self._activated_debounce = false
connection_bin_module.insert(self._connection_bin, self._client_caster.HumanoidCollided:Connect(function(...)
on_hit(self, ...)
end))
combo_module.init(self._combo)
connection_bin_module.insert(self._connection_bin, self.action_event:Connect(function()
on_activated(self)
end))
end
return weapon
I tried to use a constant debounce time, in case the server’s tick was desynchronized. That did not help.
I tried to eliminate the effects. Did nothing.
I thought that maybe the signal module was acting up, i tried using BindableEvents instead. Did nothing.
I thought that maybe the knockback manipulating the network owner could cause some weird issues, i removed it. nothing.
I thought that the damage/combo modules might have been problematic, I removed them from the code and still had the same issue.
I don’t know what to do anymore. Any help is appreciated.