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

How do you use the :MoveTo() command?

Asked by 5 years ago

Hello I have made questions about this in the past, but none of the answers seemed to help. as when I load in the game and the script is supposed to activate it doesn't work?

Here is the script i made but it doesn't move the character when they join at all. Please help

function onPlayerEntered(newPlayer)
    wait(0.5)
    do game.Players.PlayerName.Character:MoveTo(Vector3.new(0.06, 1, -454.194))
    end
end

2 answers

Log in to vote
0
Answered by
aem92 10
5 years ago
Edited 5 years ago

It's easier to just change the character's cframe, MoveTo is for models.

game.Players.PlayerName.Character.PrimaryPart.CFrame = CFrame.new(position)
Ad
Log in to vote
0
Answered by 5 years ago

As I see, you want to use a :MoveTo() command. You didn't tell us, do you get anything highlighted in red or orange. When you are teleporting a player, it's easier to use :SetPrimaryPartCFrame(), but you need to have defined PrimaryPart in your Model. As I see, you want to teleport a player, so Player already has defined PrimaryPart, so it's easy to teleport it! Here's the code that will help you:

Make sure to put this code in a LocalScript inside of a ScreenGui, you can name it however you want!

local Player = game:GetService("Players").LocalPlayer

game.Players.PlayerAdded:Connect(function()

    local char = Player:WaitForChild("Character")

    char:SetPrimaryPartCFrame(CFrame.new(0.06, 1, -454.194))

    --[[If you need to rotate the model, just replace line 7 with: char:SetPrimaryPartCFrame(CFrame.new(0.06, 1, -454.194) * CFrame.Angles(0, 0, 0))
Those three zeros on the end are orientation for the model!
]]
end)

Hope I helped you this time! ^_^

Answer this question