Basically, I made an ability on the sword where you stab them with the sword, they stick to the sword(using weld) and then you slam them multiple times on the ground. The ability works properly, but for some reason when you actually kill the opponent using the ability, it kills you as well which isnt supposed to happen. Help would be appreciated.

Script: (damage is at the bottom)

ame.ReplicatedStorage.Trident.OnServerEvent:Connect(function(player)
	local debounce = false
	local char = player.Character
	local sword = char:FindFirstChild("Trident")
	
	wait(.7)
	
	sword.Handle.Swing:Play()
	
	sword.Handle.Touched:Connect(function(hit)
		if hit.Parent:FindFirstChild("Humanoid") then
			if hit.Parent.Name ~= player.Name then
				if debounce == false then
					debounce = true
					sword.Handle.stab:Play()
					
					local ws = char.Humanoid.WalkSpeed
					local wss = hit.Parent.Humanoid.WalkSpeed
					
					char.Humanoid.WalkSpeed = 0
					wait()
					char.HumanoidRootPart.Anchored = true
					
					hit.Parent.Humanoid.WalkSpeed = 0
					
					local w = Instance.new("Weld")
					w.Parent = sword.Handle
					w.Part0 = hit.Parent.HumanoidRootPart
					w.Part1 = sword.Handle
					w.C0 = CFrame.new(1,0,4) * CFrame.fromEulerAnglesXYZ(math.pi/.5,5,0)
					
					local stunned = Instance.new("BoolValue")
					stunned.Name = "Stunned"
					stunned.Parent = hit.Parent
					
					local stunned2 = Instance.new("BoolValue")
					stunned2.Name = "Stunned"
					stunned2.Parent = char
					
					local anim = Instance.new("Animation")
					anim.AnimationId = "https://www.roblox.com/asset/?id=11498419824"
					local playAnim = char.Humanoid:LoadAnimation(anim)
					playAnim:Play()
					
					
					if hit.Parent.Humanoid:FindFirstChild("creator") then
						hit.Parent.Humanoid.creator:Destroy()
					end
					
					local CreatorTag = Instance.new("ObjectValue")
					CreatorTag.Name = "creator"
					CreatorTag.Value = player	
					CreatorTag.Parent = hit.Parent.Humanoid
					
					wait(0.5)
					
					local OR = hit.Parent.HumanoidRootPart.Orientation
					
					hit.Parent.HumanoidRootPart.Orientation = hit.Parent.HumanoidRootPart.Orientation + Vector3.new(90,0,0)
					
					wait(1.2) -- Slam 1
					
					sword.Handle.Slam:Play()
					sword.Handle.bam:Play()
					
					if hit.Parent:FindFirstChild("Defence") then
						hit.Parent.Humanoid:TakeDamage(5)
						if char:FindFirstChild("Buff") then
							hit.Parent.Humanoid:TakeDamage(7.5)
						end
					else
						hit.Parent.Humanoid:TakeDamage(10)
						if char:FindFirstChild("Buff") then
							hit.Parent.Humanoid:TakeDamage(13)
						end
					end
					

2 comments

0

Do you and the opponent take damage? Or does it only kill both of you?

0

It just kills both of us.