hi
currently, animations are played on the client with a remote event that fires the server when damage is supposed to be done (using animation events)
i cannot rely on animations replicating to server because NPCS will use the same code and their animations dont replicate
the problem with my solution is that there is a variance in when the hitbox is activated, creating it at different positions each time
i dont want this
what do i do
client
local c3
c3 = loadedAnim:GetMarkerReachedSignal("Damage"):Connect(function(param)
events.Damage:FireServer(tool)
end)
server
function module.MeleeDamage(player, weapon)
local config = weaponsFolder:FindFirstChild(weapon.Name)
if config then
config = require(weaponsFolder:WaitForChild(weapon.Name))
local hits = createHitbox(player, weapon.Handle.Hitbox.CFrame, weapon.Handle.Hitbox.Size)
if hits then
for i, v in ipairs(hits) do
if canDamage(v) then
v.Humanoid:TakeDamage(config.Damage)
events.Animate:FireAllClients(v, rs.Animations.Hit)
events.Particle:FireAllClients("HitEffect", v.PrimaryPart.CFrame)
end
end
end
end
end
function createHitbox(player, cframe, size)
local doVisualize = true
local config = OverlapParams.new()
config.FilterDescendantsInstances = player.Character:GetDescendants()
config.FilterType = Enum.RaycastFilterType.Exclude
local hits = workspace:GetPartBoundsInBox(cframe, size, config)
local successfulHits = {}
if hits then
for i, v in ipairs(hits) do
local model = v:FindFirstAncestorOfClass("Model")
if model then
local humanoid = model:FindFirstChild("Humanoid")
if humanoid then
if model ~= player.Character then
if not table.find(successfulHits, model) then
table.insert(successfulHits, model)
end
end
end
end
end
end
if doVisualize then
local part = Instance.new("Part")
part.Size = size
part.CFrame = cframe
part.Anchored = true
part.CanCollide = false
part.BrickColor = BrickColor.new("Really red")
part.Transparency = 0.5
if successfulHits[1] then
part.BrickColor = BrickColor.new("Lime green")
end
part.Parent = workspace
debris:AddItem(part, 1)
end
return successfulHits
end