So I have a script which when a player clicks a button, a clone of an npc comes forward to ask the person what he wants. This thing doesn't seem to work for me. Any help? Here is my script:
local de = 1 function onTouch(plr) if de == 1 then de = 2 print("recieved") local char = game.Workspace.NPC:Clone() local torso = char:FindFirstChild("HumanoidRootPart") -- The humanoid root part of the cahracter local pos = (torso.CFrame:pointToWorldSpace(Vector3.new(0, 0, 10))) -- A position from the world space, 5 studs to the left of the humanoid root part. local hum = char:WaitForChild("Humanoid") -- Identifies the humanoid of the player. hum.WalkToPoint = pos -- Changes the walking point of the humanoid to walk towards that position. end end script.Parent.ClickDetector.MouseClick:Connect(onTouch)
MoveTo() on a model will teleport that model to the given location based on a Vector3, similar to how SetPrimaryPartCFrame (however that takes a CFrame value)
If you want to an NPC then you should be using MoveTo on that NPC's humanoid rather then the model itself. Please see the Wiki next time.
local Humanoid = char:WaitForChild("Humanoid") local Location = Vector3.new(0, 0, 10) Humanoid:MoveTo(Location)