im having this issue on the line 46 how can i fix?

local Active = false
local HitNumber = 0
local DebrisService = game:GetService("Debris") --Literally the least efficient way to do this but I couldn't figure out anything else :/
game.ReplicatedStorage:WaitForChild("SwingEvent").OnServerEvent:Connect(function(player)
	local char = player.Character or player.CharacterAdded:Wait()
    local humanoid = char.Humanoid
	local Stats = player:WaitForChild("PlrStats"):WaitForChild("Stats")
    local Strength = Stats:WaitForChild("Strength")
	Active = true
	delay(.0,function()
	local attachment0 = Instance.new("Attachment",player.Character.Sword.BackWeld)
	attachment0.Position = Vector3.new(0, 0, 0)CFrame.Angles(math.pi/6, 8, 7)
	local attachment1 = Instance.new("Attachment",player.Character.Sword.BackWeld)
	attachment1.Position = Vector3.new(0,0,0)CFrame.Angles(5, 5, 5)
	local trail = player.Character.Sword.Sword.TrailSkill
	trail.Attachment0 = attachment0
	trail.Attachment1 = attachment1
	delay(1,function()
	attachment0:Destroy()
	attachment1:Destroy()
	end)
	end)
	
	local Folder = Instance.new("Folder",workspace)
	Folder.Name = "Punching"
	
	DebrisService:AddItem(Folder,2)
	
	HitNumber = HitNumber + 1
	
	
		local swinganim = Instance.new("Animation")
	swinganim.AnimationId = game:GetService("ReplicatedStorage"):WaitForChild("SwordConfiguration").Swing2.Value
	local swinganimtrack = player.Character.Humanoid:LoadAnimation(swinganim)
	swinganimtrack:Play()
	player.Character.Sword.Sword.Swing:Play()
    local Root = player.Character:WaitForChild("HumanoidRootPart")
	
	local HitBox = Instance.new("Part",Folder)
		HitBox.CFrame = char:WaitForChild("Sword"):WaitForChild("Sword").CFrame
		HitBox.Size = Vector3.new(8,6,5)
		HitBox.Transparency = 1
		HitBox.Massless = true
		HitBox.CanCollide = false
		HitBox.Touched:Connect(function(Hit)
			if Hit.Parent == char or Hit.Parent.Parent == char then
				return

			elseif not Hit.Parent:FindFirstChild("Dodge") or not Hit.Parent.Parent:FindFirstChild("Dodge") then
				local Humanoid = Hit.Parent:FindFirstChild("Humanoid") or Hit.Parent.Parent:FindFirstChild("Humanoid")
				
				if Humanoid and not Humanoid:FindFirstChild("Attacker") then
					Folder:Destroy()
					
					local Attacker = Instance.new("ObjectValue",Humanoid)
					Attacker.Name = "Attacker"
					Attacker.Value = player
					DebrisService:AddItem(Attacker,0.5)
					
					Humanoid:TakeDamage(Strength.Value/3.2+5)
				end
				end
		
	end)

	Active = false
	for i,v in pairs(game:GetService("ReplicatedStorage").HitVals:GetChildren()) do
		v:Destroy()	
	end
end)


5 comments

0

Are you defining "Hit"?

0

ake sure hit isnt nil

0

make*

0

make sure hit isnt nil

0

how can i make it