So I have a game I'm working on. Only issue. The Sword (Katana) Hit Detection Works (But most of the time not)

This is the code (Server Of Course)

A = Sword.Touched:Connect(function(Hit) -- A is a varible to disconnect the touch event later
						local Humanoid = Hit.Parent:FindFirstChild("Humanoid") -- Defines And Check if the humanoid exists
						if not tableContains(C,Hit.Parent.Name) then -- Check if the player tabe does not contain the other player
							if Humanoid then -- Checks if the humanoid exists
								local Damage = math.random(5,20) -- Generates a random damage
								Humanoid:TakeDamage(Damage) -- Damages the humanoid
								local DC = game.ServerStorage.BilboardUIs.DmgIndicator:Clone() -- Clones the damage indicator
								DC.TextLabel.Text = "-"..Damage -- Sets the text to how much damage was dealt
								DC.ExtentsOffset = Vector3.new(math.random(0,2),math.random(2,4),math.random(0,2)) -- Makes it spawn in a random location
								DC.Parent = Hit.Parent.Head -- Sets the parent
								spawn(function() -- Spawns a new thread
									wait(0.3) -- Waits .3 Seconds
									DC:Destroy() -- Destroys The Damage Indicator
								end)
								table.insert(C, 1, Hit.Parent.Name) -- Add the player (or NPC) To make sure you cant double hit in one combo.
							end
						end
					end)

Sorry for all of the comments I wanted it to be as easy to understand as possible.

3 comments

0

I doubt this is the issue but use coroutine.wrap instead of spawn.

0

maybe you do remove the player from the table again, but cant see it here

0

The spawn function is somthing i use just for shor things to run on a simple other thread. And removing the player isint needed as they are all in combo functions encased in one function.