I just realized that humanoid damaging himself is not a real problem. The problem is HumanoidRootPart weld. I want to make a Kamehameha that pushes back the target, but both the target and attacker die when trying to weld the target’s HumanoidRootPart or Torso to BlastPart2, which is the end of the energy wave.
local function onHitboxTouched(otherPart)
local otherCharacter = otherPart.Parent
local otherHumanoid = otherCharacter:FindFirstChild("Humanoid")
local otherHumanoidRootPart = otherCharacter:FindFirstChild("HumanoidRootPart")
local chargedKi = charge.Value/90
local damage = 10 + 90 * chargedKi
if otherHumanoid and otherHumanoid ~= humanoid and otherHumanoidRootPart then
-- local rootWeld = Instance.new("Weld")
-- rootWeld.Name = "RootWeld"
-- rootWeld.Part0 = blastPart2
-- rootWeld.Part1 = otherHumanoidRootPart
-- rootWeld.Parent = blastPart2
hitboxPart:Destroy()
delay(0, function()
repeat wait() until blastPart2.Transparency < 1
otherHumanoid:TakeDamage(damage)
end)
end
end
hitboxPart.Touched:Connect(onHitboxTouched)
The commented section is what’s going on. When I weld the HumanoidRootPart of a player to a part who belongs to another player, both players die. How can I do this without killing both players?
First off, I’ll start by saying you should consider making some animations with the Animation Editor, rather than using all that Weld modification stuff.
After that, try putting a “if otherHumanoid == humanoid then return end” in the damage function. This will stop the rest from running if the humanoid it hits is the same as the player’s humanoid.
This would help in verifying that you indeed have the right humanoids. If possible, provide a .rbxl file for the place so we can test the same as well.
On another note, please use #development-support:scripting-support for help, this category is not apt for it.
If you keep on hitting yourself, then maybe try a if Hit:IsADescendentOf function. This’ll see if the Wave came from a player, if it did, then it would avoid being hit. Hope this helps!
@BanCredit, the debugging you recommended me shows this: Workspace.Player1.Humanoid Workspace.Player2.Humanoid
Which suggests it’s differentiating your humanoid from the other humanoid correctly. I tried doing what @Zeezy666 and @plasmascreen suggested, but nothing changed at all. The enemy keeps countering the energy wave and damaging the attacker no matter how many checks I do for some reason. I’ve edited the post with what you guys suggested and added the .rbxl file.
@Drinkinix, can you be more specific? I never worked with that instance, and an example would be helpful.
local AlreadyDamaged = {}
MainShockwave.Touched:Connect(function(Hit)
if not Hit:IsDescendantOf(Character) and Hit.Parent:FindFirstChild('Humanoid') then
local Humanoid = Hit.Parent.Humanoid
if AlreadyDamaged[Humanoid] ~= true then
AlreadyDamaged[Humanoid] = true
Humanoid:TakeDamage(Damage) -- Add formula for level + stats
local BV = Instance.new("BodyVelocity")
BV.MaxForce = Vector3.new(100000,100000,100000)
BV.Velocity = MainShockwave.CFrame.lookVector*-200
BV.Parent = Hit
Debris:AddItem(BV, .5)
if PlayersService:GetPlayerFromCharacter(Hit.Parent) ~= nil then
ShakeCamera(PlayersService:GetPlayerFromCharacter(Hit.Parent))
end
end
end
end)
The “if not Hit:IsDescendantOf(Character)” means if the “something” was casted by a player, it won’t damage the player, but damage another person when touched. (This script won’t help with your game, but it is something that will get you started.) Hope this helps!
I updated the post. The problem has nothing to do with otherHumanoid ~= humanoid being ignored. Sorry, my assumption made no sense at all. I’ll analyze the script further next time.
How can I work around this limitation? I tried changing the Part0, Part1, and Parent of the weld, no luck. I also tried using WeldConstraints and Motor6Ds instead of Welds, and nothing changed at all. Do I have to ignore what I’m trying to do and come up with another hit effect? I hope that’s not the case, or I’ll be very frustrated because I could do such things without complications before they forced us to make games with FilteringEnabled.