Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Humanoid:MoveTo - Walks instead of Teleports?

Asked by 8 years ago
Tool = script.Parent

function onTouched(hit)
        if hit.ClassName == "Part" then
            local Humanoid = script.Parent.Parent.Parent.Parent:WaitForChild("Humanoid")
            if Humanoid then
                Humanoid:MoveTo(hit.Position)
            end
        return; 
    end
end

Tool.Touched:connect(onTouched)

The script above works perfectly fine, although, at the part:

Humanoid:MoveTo(hit.Position)

I'm not getting any errors, it's just the player moves towards that location rather than teleporting to that position, not sure why it does this. Any help would be useful.

3 answers

Log in to vote
5
Answered by
1waffle1 2908 Trusted Badge of Merit Moderation Voter Community Moderator
8 years ago
Edited 7 years ago

Humanoid:MoveTo makes humanoids walk. Model:MoveTo teleports a model. You want to teleport the character instead of telling its humanoid to walk. Write Humanoid.Parent:MoveTo(hit.Position) to teleport the character model.

Ad
Log in to vote
1
Answered by 8 years ago

1Waffle1's answer is good, but if you're looking for an alternative, change the player's torso's CFrame:

mouse.Button1Down:connect(function()
    char.Torso.CFrame = mouse.Hit.p + Vector3.new(0,7,0) -- so the player doesn't teleport into the ground/wall/whatever
end
Log in to vote
-2
Answered by 8 years ago

If you wan't him/her to teleport to a location, you use X, Y, Z coordinations.

0
I want the player to teleport to the .hit which is why I am asking the question. Moderance 30 — 8y

Answer this question