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.
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.
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)
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)
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