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

why cant i use the MoveTo method to move a character to a part?

Asked by 10 years ago
teleport = game.Workspace.teleport
function MoveTo()
    game.Players.LocalPlayer.Character:MoveTo(teleport)

script.Parent.MouseButton1Down:connect(MoveTo)

this is in a regular script not local

0
Try again HexC3D 830 — 10y

3 answers

Log in to vote
2
Answered by
HexC3D 830 Moderation Voter
10 years ago

First of all you can't can't use Local Player in a regular script, second of all your not using position or CFrame..

First of all put this in a local script. Put the following inside StarterGui in order.

SCREENGUI

FRAME

TextButton

SCRIPT

local player = script.Parent.Parent.Parent.Parent
Workspace = game:GetService('Workspace')
script.Parent.MouseButton1Down:connect(function()
player.Character.Humanoid:MoveTo(Workspace.teleport.Position,Workspace.teleport)
end)

That should work once you put it in a local script, mk. For this to work you have to make sure 'teleport' actually exists also.

If this helped +1, if this answered your question check mark.

0
hex, so i tried your script but it doesnt seem to be working,, the teleport is in workspace and i put it in a local script namelessassasin 30 — 10y
0
no kidding, i tried your script again and it still does not work, i did everything u said to do, i dont know why its not working namelessassasin 30 — 10y
Ad
Log in to vote
0
Answered by 10 years ago

You've made the mistake that I've made dozens of times when working with properties and Values. You define "teleport" at the beginning as a Part inside the Workspace, and then tell the script to move the character to the brick itself. MoveTo() needs a Vector3 value, so you have to write MoveTo(teleport.Position) for it to send the player to the Position where said brick is.

Log in to vote
0
Answered by 10 years ago
teleport = game.Workspace.teleport
function MoveTo()
    game.Players.LocalPlayer.Character:MoveTo(teleport.position)
end
script.Parent.MouseButton1Down:connect(MoveTo)

Simple solution, You forgot an end and that moving models relies on a position and not a part.

Answer this question