My issue: when I swing my swords and it detects that it hit me (the one swinging the swords) it damages all dummies at the same time.
here’s my LocalScript located in StarterCharacterScripts (Enabled and Disabled upon AnimationEvents):
local Hitbox1 = script.Parent["Right Arm"]:WaitForChild("Handle").Holder.Blade:WaitForChild("Hitbox1")
local Hitbox2 = script.Parent["Left Arm"]:WaitForChild("Handle2").Holder.Blade:WaitForChild("Hitbox2")
local HitHumanoid = game.ReplicatedStorage.HitHumanoid
local SelfHumanoidHit = game.ReplicatedStorage.SelfHumanoidHit
local SelfHumanoid = script.Parent.Humanoid
local Debris = game:GetService("Debris")
while true do
task.wait(0.01)
local Hitbox1Clone = Instance.new("Part", workspace)
Hitbox1Clone.Name = "Hitbox1"
Hitbox1Clone.Size = Vector3.new(1.025, 1.46, 5.43)
Hitbox1Clone.Anchored = true
Hitbox1Clone.Transparency = 0.5
Hitbox1Clone.CanCollide = false
Hitbox1Clone.Color = Color3.new(1, 0, 0)
Hitbox1Clone.Massless = true
Hitbox1Clone.CanTouch = true
Hitbox1Clone.Position = Hitbox1.Position
Hitbox1Clone.Orientation = Hitbox1.Orientation
Debris:AddItem(Hitbox1Clone, 1)
local Hitbox2Clone = Instance.new("Part", workspace)
Hitbox2Clone.Name = "Hitbox2"
Hitbox2Clone.Size = Vector3.new(1.025, 1.46, 5.43)
Hitbox2Clone.Anchored = true
Hitbox2Clone.Transparency = 0.5
Hitbox2Clone.CanCollide = false
Hitbox2Clone.Color = Color3.new(0, 0, 1)
Hitbox2Clone.Massless = true
Hitbox2Clone.CanTouch = true
Hitbox2Clone.Position = Hitbox2.Position
Hitbox2Clone.Orientation = Hitbox2.Orientation
Debris:AddItem(Hitbox2Clone, 1)
Hitbox1Clone.Touched:Connect(function(hit)
local Humanoid = hit.Parent:FindFirstChildOfClass("Humanoid")
if Humanoid then
print("hit1 other humanoid!")
HitHumanoid:FireServer()
Hitbox2Clone.CanTouch = false
end
end)
Hitbox2Clone.Touched:Connect(function(hit)
local Humanoid = hit.Parent:FindFirstChildOfClass("Humanoid")
if Humanoid then
print("hit2 other humanoid!")
HitHumanoid:FireServer()
Hitbox1Clone.CanTouch = false
end
end)
--------------SELF HIT---------------
Hitbox1Clone.Touched:Connect(function(hit)
if hit.Parent == script.Parent.Humanoid then
SelfHumanoidHit:FireServer()
print("Hit Self")
end
end)
Hitbox2Clone.Touched:Connect(function(hit)
if hit.Parent == script.Parent.Humanoid then
SelfHumanoidHit:FireServer()
print("Hit Self")
end
end)
end
And the ServerScript inside the dummies:
local HitHumanoid = game.ReplicatedStorage.HitHumanoid
local SelfHumanoidHit = game.ReplicatedStorage.SelfHumanoidHit
HitHumanoid.OnServerEvent:Connect(function()
script.Parent.Humanoid:TakeDamage(50)
end)
SelfHumanoidHit.OnServerEvent:Connect(function()
script.Parent.Humanoid:TakeDamage(0)
end)
This all happens when the swing animations reach animation events DamageStart
and DamageEnd
. I’ve tried doing elseif hit.Parent == SelfHumanoid then
but when I do this, it doesn’t do anything. Please help!
Video Example of dummies all dying: