Touched not working?

So I tried to make punch but touched is not working, even not printing touch. (I tested if right arm exist in workspace and it was) what is problem?

hitscan = nil
hitscan = player.Character.RightHand.Touched:Connect(function(other)
			pcall(function()
				print("touch")
				if hitSucess == false and player.pvpValues.inAttack.Value == true then
					print("hit able")
					if other.Parent:FindFirstChildOfClass("Humanoid") then
						if other.Parent ~= player.Character then
							hitSucess = true
							other.Parent.Humanoid.Health -= 15
							hitscan:Disconnect()
						end
					end
				end
			end)
		end)
1 Like

Remove it from the pcall so we can see if it’s erroring?

local hitscan = nil
hitscan = player.Character.RightHand.Touched:Connect(function(other)
	print("touch")
	if hitSucess == false and player.pvpValues.inAttack.Value == true then
		print("hit able")
		if other.Parent:FindFirstChildOfClass("Humanoid") then
			if other.Parent ~= player.Character then
				hitSucess = true
				other.Parent.Humanoid.Health -= 15
				hitscan:Disconnect()
			end
		end
	end
end)
1 Like

removed pcall and tested, still same. no errors, not printing touch still

1 Like

What type of script is it and where is it located?

1 Like

server sided, server script service.

–hitscan line…
spawn(function()
wait(0.7)
pcall(function()
hitscan:Disconnect()
print(“end”)
end)

printing end but not touch

Wait what’s the entire code of the script since I think you’re leaving some liens out since it should work? Maybe it’s that spawn thing you’ve shown right now that’s disconnecting it too soon? I need a bit more info

local ReplicatedStorage = game:GetService("ReplicatedStorage")

ReplicatedStorage:FindFirstChild("right atk").OnServerEvent:Connect(function(player)
	if player.pvpValues.inpvp.Value ~= true and player.pvpValues.rightPunch.Value == false and player.pvpValues.inAttack.Value == false then
		player.pvpValues.inAttack.Value = true
		player.pvpValues.rightPunch.Value = true
		player.Character.HumanoidRootPart.Anchored = true
		local hitSucess = false
		local hitscan = nil
		hitscan = player.Character.RightHand.Touched:Connect(function(other)
			print("touch")
			if hitSucess == false and player.pvpValues.inAttack.Value == true then
				print("hit able")
				if other.Parent:FindFirstChildOfClass("Humanoid") then
					if other.Parent ~= player.Character then
						hitSucess = true
						other.Parent.Humanoid.Health -= 15
						hitscan:Disconnect()
					end
				end
			end
		end)
		local Anim = game:GetService("ServerStorage").anims.normalAtk.heavyPunch:Clone()
		local Motion = player.Character.Humanoid:LoadAnimation(Anim)
		Motion:Play()
		spawn(function()
			wait(0.7)
			pcall(function()
				hitscan:Disconnect()
				print("end")
			end)
			player.pvpValues.inAttack.Value = false
			player.Character.HumanoidRootPart.Anchored = false
			wait(0.6)
			player.pvpValues.rightPunch.Value = false
		end)
	end
end)

I got whole script here

Could it be this spawn function? Since it’s disconnecting it 0.7 seconds after making it, try increasing the wait to something higher like 5 seconds to see if that’s the culprit

I tested it with out Disconnect(), it prints touch but not dealing dmg also it only prints “touch” when it’s not attacking time (only works when touching in normal status)

1 Like

It’s probably not dealing damage because either hitSucess or player.pvpValues.inAttack.Value are not false or true respectively, print those values. Also you can disconnect it at the very end of the event in needed

1 Like