hello robloxians,
i tried to make npc that teleport to brick when player comming to him but there is a bug inside my script.
can anyone tell me how to fix that?
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") ~= nil then
script.Parent.Parent.Humanoid.MoveToFinished(workspace.ForestTeleport.TP1.CFrame)
end
end)
thanks for help,
REALINONOOBYT.
This is the working script:
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") ~= nil then
script.Parent.Parent.Humanoid:MoveTo(workspace.ForestTeleport.TP1.CFrame)
end
end)
You should test your scripts before making a topic.
1 Like
thanks for help but is still no works
Can you show us a video with him walking? Do are there any error? What is the NPC’s walkspeed? Are you sure TP1 is a basepart?
1 Like
Change the code into this:
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") ~= nil then
script.Parent.Parent.Humanoid:MoveTo(workspace.ForestTeleport.TP1.Position)
end
end)
Seriously, please check your errors.
1 Like
i already tried this and is still same.
Position is a Vector3 so it is clearly you don’t tried. If you tried this is inpossible to have the same error.
1 Like
when i used .Position there was no errors but the npc didnt walk
Why are you using Humanoid? You should use HumanoidRootPart.
1 Like
there is no HumanoidRootPart inside my npc maybe that was all the problem?
Can you show us a video where you touch the npc and he is not walking? What is it’s walk speed? Also, only R15 Characters are having HumanoidRootPart so it is not a problem. You should also add a debunce.
Also, @FlashFlame_Roblox He wants to make the character to walk not to teleport.
1 Like
i am want to teleport no walk.
If you want to move a model you have to have a PrimaryPart. And then do the :MoveTo() with the PrimaryPart
@TheTurtleMaster_2 Your script is used for teleporting.
1 Like
Then simply do this:
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") ~= nil then
script.Parent.Parent:MoveTo(workspace.ForestTeleport.TP1.Position)
end
end)
1 Like
My script isn’t teleporting, my script is used to make the NPC walk, not teleport. Please read the code instead of saying random stuff. Where do you see the teleporting part?
1 Like
So :MoveTo isn’t for teleporting?
1 Like
MoveTo on humanoid is Walking, MoveTo on models is teleporting.
1 Like
Oh ok (30 charsssssssssssssssss)
1 Like
If you just want to teleport the npc to the brick, why not do this ?
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then -- if there is a hum
print("a humanoid touched this")
script.Parent.Parent.PrimaryPart.CFrame = workspace.ForestTeleport.TP1.CFrame -- teleport the model !The model needs to have a primarypart!
print(script.Parent.Parent.Name.." Has been teleported")
end
end)
2 Likes