My goal: when the NPC touches “TouchPartN” it will do NPC.Humanoid:MoveTo(Vector3.new(18.426, 8.146, 36.175))
The reason I am asking for help on this is because I don’t know how to make it ONLY detect a certain thing (in my case “NPC”).
My goal: when the NPC touches “TouchPartN” it will do NPC.Humanoid:MoveTo(Vector3.new(18.426, 8.146, 36.175))
The reason I am asking for help on this is because I don’t know how to make it ONLY detect a certain thing (in my case “NPC”).
.Touched, and check if the name of the model is the name of the NPC. If true then teleport
Refer to the sample code below, the event ya need is BasePart.Touched
local Part = ...
local NPC = ...
Part.Touched:Connect(function(Hit)
if Hit:IsDescendantOf(NPC) then
NPC.Humanoid:MoveTo(Vector3.new(18.426, 8.146, 36.175))
end
end
I got no errors but I didn’t work
Send ya code here please perhaps ya got the references to the constants wrong
Here, you also forgot to add a ) on the second end but I fixed that for you
local NPC = game.Workspace.NPC
local humanoid = NPC.Humanoid
local Part = game.Workspace.TouchPartN
Part.Touched:Connect(function(Hit)
if Hit:IsDescendantOf(NPC) then
NPC.Humanoid:MoveTo(Vector3.new(18.426, 8.146, 36.175))
end
end)
Ya understand that the Model NPC needs to come in to physical contact to the part for the code in the event to fire right, and you’re not usin the humanoid constant either.
I’m still confused, I used the sample Roblox gave and fixed it to my layout but even then it doesn’t work.
Is this a LocalScript or Script, is the code even runnin
It’s in a Script
I’m not sure if it is running, but I think so.
Where is the Script parented to, add a print or warn at the top of the script and see if the contents appear in the console
Okay sorry for late response, no, it is not detecting that the NPC (model) touches TouchPartN