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

Help with MoveTo function?

I am wondering if on line 3 of this code would work if I found a specific object in a Vector3.

function GetPlayers()
	for i,v in pairs(game.Players:GetPlayers()) do
		v.Character.MoveTo(Vector3.new(game.Workspace:FindFirstChild("Map").TP.Position)) --Here
	end
end

2 comments

0

game.Workspace.Map.CFrame

1

Could it be game.Workspace.Map.TP.CFrame?

1 answer

MoveTo is a function!

Remember when calling a function you use ':' not '.' as it's not a property.

'v.Character.MoveTo'... should be 'v.Character:MoveTo'

Position is a Vector3 value not a CFrame value!

'TP.Position' ... should be 'TP.CFrame' assuming it's a part of some-sort.

Your code should look like this:

function GetPlayers()
    for i,v in pairs(game.Players:GetPlayers()) do
        v.Character:MoveTo(Vector3.new(game.Workspace:FindFirstChild("Map").TP.CFrame)) --Here
    end
end

2 comments

0

You said "Position is a Vector3 value not a CFrame value!" but then why did you keep "TP.CFrame"?

0

Because CFrame is a CFrame value not a Vector3 value.

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