Touch event won't fire!

So I have a script where you touch the trigger part and it creates a new segment to go after it. But when I touch the trigger, it doesn’t fire and does nothing. It was working earlier but it is not anymore and I don’t know why.

Script:

local function createSegment(hit)

print("E")

end

script.Parent.Trigger.Touched:Connect(createSegment)

I also have a debounce and an if statement that checks for the humanoid but it just doesn’t fire!

I didn’t put the rest of the script because I don’t think it is necessary because it just clones the model from replicated storage.

try something like this


debounce = false

script.Parent.Touched:connect(function(hit)
	if not debounce then
		debounce = true
		if(hit.Parent:FindFirstChild("Humanoid")~=nil)then
			local player = game.Players:GetPlayerFromCharacter(hit.Parent)
--WHAT YOU WANT IT TO DO IN HERE
			wait(1)
		end
		debounce = false
	end
end)

If it still doesn’t work I can’t help, also this is for humanoids touching it only.

Still doesn’t work, should I just restart studio and see if it works then?

if that doesnt work it may be the script your putting inside the thing, you should try something you can guarantee works and put it in there

if it works when you change it, its your clone replicated storage stuff

Parts have a property called “CanTouch”. Make sure that you haven’t set that to false

1 Like

Is it a LocalScript or a Script. And where did you place it in?

1 Like

It is a server script and I put it under the model that is the segment that the players go on.

The script should be inside a Part. Not model, Models dont have a .Touched event.

local part = script.Parent --must be a part

part.Touched:Connect(function(hit)

local players_serv = game:GetService("Players")
local player = players_serv:GetPlayerFromCharacter(hit:FindFirstAncestorOfClass("Model"))

if player then

print("i am the man behind the slaughter")

end

end)

should work ^^

1 Like

As you can see from my script, I referenced a part within the model for the touch event.

Create a folder for the model, script and trigger.
Take the trigger and the script out of the model if that’s where they are.
Make sure the part “CanTouch = true”
[New Folder]
→ Model
→ Script
→ Part

local trigger = script.Parent.Trigger
trigger.Touched:Connect(function(hit)
    print("Rip & Tear until it is done")
end)

Then there’s no reason for it not to work? If it’s a severscript and it’s inside the part

It should work. Very basic “Touch” functionality. I know sometimes it can get janky depending on where the script and part are located so if you just make a folder and separate everything then you can get it working on some level.

Also, maybe set the model itself to “CanTouch = false”. So it’s not causing any unexpected issues on the trigger.

I hate .Touched events, they fire 1205012065 times per second, you have to add a bunch of debounce values, and yes the CanTouch value is a problem now too :disappointed:

1 Like