GetPlayerFromCharacter dont work

this script didnt work

dont know why I tried my best

Sword.Touched:Connect(function(Touch)
	if Touch.Parent:FindFirstChild("Humanoid") and Attacking == true then
		print("hit")
		AttackedTarget = Players:GetPlayerFromCharacter(Touch.Parent)
		if Touch.Parent.Humanoid:GetAttribute("Blocking") == true then
			print("Blocked")
			remoteEvent:FireClient(AttackedTarget, "Blocked")
			Touch.Parent.Humanoid:TakeDamage(Damage/5)
		elseif Touch.Parent.Humanoid:GetAttribute("Parrying") == true then
			print("PARRIED!")
			remoteEvent:FireClient(AttackedTarget, "Parried")
		elseif Touch.Parent.Humanoid:GetAttribute("Iframe") == true then
			print("Dodged")
			remoteEvent:FireClient(AttackedTarget, "Dodge")
		else
			Touch.Parent.Humanoid:TakeDamage(Damage)
			remoteEvent:FireClient(AttackedTarget, "Hitted")
		end
		Attacking = false
	end
end)
1 Like

Is there an error that pops up?

The registered touch part may be part of an accessory, hence the parent would be an accessory.

Try this:

Sword.Touched:Connect(function(Touch)
	for _, Player in ipairs(game:GetService("Players"):GetPlayers()) do
		if Player.Character:IsAncestorOf(Touch) and Attacking == true then
			print("hit")
			AttackedTarget = Player
			if Touch.Parent.Humanoid:GetAttribute("Blocking") == true then
				print("Blocked")
				remoteEvent:FireClient(AttackedTarget, "Blocked")
				Touch.Parent.Humanoid:TakeDamage(Damage/5)
			elseif Touch.Parent.Humanoid:GetAttribute("Parrying") == true then
				print("PARRIED!")
				remoteEvent:FireClient(AttackedTarget, "Parried")
			elseif Touch.Parent.Humanoid:GetAttribute("Iframe") == true then
				print("Dodged")
				remoteEvent:FireClient(AttackedTarget, "Dodge")
			else
				Touch.Parent.Humanoid:TakeDamage(Damage)
				remoteEvent:FireClient(AttackedTarget, "Hitted")
			end
			Attacking = false
			break
		end
	end
end)

Your script dont work:

no theres nothing

Try this and look for anything in the output

Sword.Touched:Connect(function(Touch)
	print("Works about to here!")
	for _, Player in ipairs(game:GetService("Players"):GetPlayers()) do
		print("Everything works here!")
		if Player.Character:IsAncestorOf(Touch) and Attacking == true then
			print("hit")
			AttackedTarget = Player
			if Touch.Parent.Humanoid:GetAttribute("Blocking") == true then
				print("Blocked")
				remoteEvent:FireClient(AttackedTarget, "Blocked")
				Touch.Parent.Humanoid:TakeDamage(Damage/5)
			elseif Touch.Parent.Humanoid:GetAttribute("Parrying") == true then
				print("PARRIED!")
				remoteEvent:FireClient(AttackedTarget, "Parried")
			elseif Touch.Parent.Humanoid:GetAttribute("Iframe") == true then
				print("Dodged")
				remoteEvent:FireClient(AttackedTarget, "Dodge")
			else
				Touch.Parent.Humanoid:TakeDamage(Damage)
				remoteEvent:FireClient(AttackedTarget, "Hitted")
			end
			Attacking = false
			break
		end
	end
end)

Where and how do you set Attacking to true?

I’m pretty sure you should be finding the player from the character’s name, not the model itself.

Edit: You never called the Attacking variable back to true, so i’m guessing the issue would be around that.

it is never set back to true but that wouldn’t stop running it at least once

and I think the attacking variable is set to true when the sword is lunged (Sword tool is activated)

local script fire server

I did

Srry im late as hell