Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

1 comment

0

Try again

3 answers

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.

2 comments

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

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

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.

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.