.Touched isn't workingg I think

script.Parent.Touched:Connect(function(thingy)
	print(thingy)
	if canParry.Value == true then
		if thingy:GetAttribute("Type") == "Projectile" then
			sound:Play()
			thingy:Destroy()
		elseif thingy:GetAttribute("Type") == "Attack" then
			soundd:Play()
			print("stun bad guy")
		else
			print("that nothing")
		end
	end
end)

its not even printing thingy for some reasonn.

image
these are the targetss (not anchored)
image
the gray box contains the script (it can’t collide)

2 Likes

my only current guess is that CanTouch might be off or something, but not entirely sure

What is the parent of the script?

Print something before the connection just to make sure that section of the code is running. That is all I can think of. If it is running double check what script.Parent is.

1 Like

Can you show us your hierarchy? Like the chidren of the part containing the script and all that.

I don’t think it has to be in replicated first in order for it to detect stuff. I’m pretty sure it will detect it as long as it runs, but someone correct me if I’m wrong.

Aight stop the cap lol I tested it and it works fine.

it not working still.
I told it to print hi and it didnt print it


video off it touching the gray partss ^^^ with Type Attribute in i

image
itts in a character and

What is “canParry” and what is the Value set to?

it false, but when I press f… it turn true for a while (its parrywindow

Okay, so the issue isn’t with this code, where are you setting the value to true at? Are you sure that’s actually being set to true?

yaa im 90 percent sure its being set to truee, also I added a newww line that is supposed to print hi

local canParry = script.Parent.Parent:WaitForChild("ParryWindow")
local sound = script.parry
local soundd = script.parry2

print("hi")

script.Parent.Touched:Connect(function(thingy)
	print(thingy)
	if canParry.Value == true then
		if thingy:GetAttribute("Type") == "Projectile" then
			sound:Play()
			thingy:Destroy()
		elseif thingy:GetAttribute("Type") == "Attack" then
			soundd:Play()
			print("stun bad guy")
		else
			print("that nothing")
		end
	end
end)

and it doesnt print hi for some reason

What’s the code for when you set the value to true? Is there any errors be logged or warning about “infinite yield possible” ?

no infinite yield

local char = script.Parent
local animate = script:WaitForChild("Parry")
local hum = char:WaitForChild("Humanoid")
local animationn = hum.Animator:LoadAnimation(animate)

local ParryWindow = char.ParryWindow

local parryCD = false

UserInputService.InputBegan:Connect(function(input, bruh)
	if not bruh and input.KeyCode == Enum.KeyCode.F and not parryCD then
		parryCD = true
		hum.WalkSpeed = 0
		ParryValueSwitcher:FireServer()
		animationn:Play()
		animationn.Stopped:Wait()
		parryCD = false
		hum.WalkSpeed = 16
	end
end)

that fire remote, here the remote::

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ParryValueSwitcher = ReplicatedStorage:WaitForChild("ParryValueSwitch")

ParryValueSwitcher.OnServerEvent:Connect(function(plr)
	local boolll = plr.Character:WaitForChild("ParryWindow")
	boolll.Value = true
	task.wait(0.3)
	boolll.Value = false
end)

Where are you creating this part you’re trying to capture the Touched event from? On the server or client?

itsss, its.

its a local script andd it go into startercharacterscripts and
image

So I think the issue is that since the part is created locally, the server doesn’t detect it – if you captured the Touched on the client and used a RemoteEvent to fire the server, it should work :slight_smile:

ok ill o that :dotted_line_face:

uh ohhh …
iut nto working