I have some models set up in order to help me test models taking damage properly for when I eventually try swapping the players to those models. However, I've only managed to get it to work correctly once and now I don't know how to do it again.
I've added screenshots of how the Rig and the Training Dummy are set up. The Dummy's Humanoid is correctly showing its HP and name, but doesn't take damage.
I'm also including a video of what's happening just in case, as well as the code that handles how hitboxes work below:
(This is a Script in ServerScriptServices)
local createHitbox = ReplicatedStorage:WaitForChild("CreateHitbox")
createHitbox.OnServerInvoke = function(plr, char, damage, size)
local hitbox = Instance.new("Part")
hitbox.Parent = workspace
hitbox.CanCollide = false
hitbox.Anchored = true
hitbox.Size = size
hitbox.BrickColor = BrickColor.new("Really red")
hitbox.Transparency = 0.5
hitbox.CFrame = char.HumanoidRootPart.CFrame * CFrame.new(0, 0, -5)
game.Debris:AddItem(hitbox, 0.2)
local damageDealt = false
hitbox.Touched:Connect(function(hit, processed)
if hit.Parent.Name ~= plr.Name and hit.Parent:FindFirstChild("Humanoid") and not damageDealt then
local dmgMult = tonumber(hit.Parent:GetAttribute("dmgMult"))
damageDealt = true
hit.Parent:FindFirstChild("Humanoid"):TakeDamage(damage * dmgMult)
end
end)
end```
** You are now Level 2! **