1
votes

I am trying to teleport the player, but every time I run the script, it teleports the player to 0,0,0 (using a classic style character):

Character.Torso.CFrame = CFrame.new(-7000, 3467, -2380.982 + (g * -10));
Character:SetPrimaryPartCFrame(CFrame.Angles(math.rad(0), math.rad(-90), math.rad(0)));

(g = 1, and character has already been defined)

@Universal Link, I tried your method (adding more arguments), and this is what I got:

Character.Torso.CFrame = CFrame.new(Character.Torso.Position, Vector3.new(-10000, 30467, -2380.982 + (g * -10)));
Character:SetPrimaryPartCFrame(CFrame.Angles(math.rad(0), math.rad(-90), math.rad(0)));

However, the character is still teleported to 0,0,0. I tried removing the second line of code by commenting it out:

Character.Torso.CFrame = CFrame.new(Character.Torso.Position, Vector3.new(-10000, 30467, -2380.982 + (g * -10)));
--Character:SetPrimaryPartCFrame(CFrame.Angles(math.rad(0), math.rad(-90), math.rad(0)));

But then the character doesn't get teleported anywhere. Also, what do you mean by referencing the CFrame with serviceprovider?

1
What are you trying to achieve with the second line? - NetherGranite
Welcome to Stack Overflow! Other users marked your question for low quality and need for improvement. I re-worded/formatted your input to make it easier to read/understand. Please review my changes to ensure they reflect your intentions. Feel free to drop me a comment in case you have further questions or feedback for me. - GhostCat
@NetherGranite, I am using it to rotate the character. - wesley bynog
@wesleybynog If I remember correctly, CFrame.Angles() returns a rotated CFrame but with a position of (0, 0, 0). You can change this position by multiplying it by another CFrame. For example, cframe = CFrame.new(32, 45, 81) * CFrame.Angles(0, 0, math.rad(90)) will make cframe have a position of (32, 45, 81) and a rotation of (0, 0, math.rad(90)). Try changing the second line to this: Character:SetPrimaryPartCFrame(Character.Torso.CFrame * CFrame.Angles(math.rad(0), math.rad(-90), math.rad(0)));. Does this work? - NetherGranite

1 Answers

0
votes

There could be a couple of things going on here...

1: In your first statement (line 1), you haven't provided CFrame with enough arguments. Take into account this statement from Roblox's Wiki:

game.Workspace.Part.CFrame = CFrame.new(Workspace.Part.Position, Vector3.new(0, 75, 75))

Vector3 allows the Lua engine to know you want to move the object 3 Dimensionally anywhere in the workspace. Otherwise the Lua engine disregards what you have put at the end and just moves the part to the center of the game (as it doesn't know what else to do).

2: The script might not be directly referencing CFrame. In my experience of animating parts in the workspace, I needed to reference the CFrame. You can do this by calling the function from serviceprovider.

Take a look at the Wiki for more information: http://wiki.roblox.com/index.php?title=CFrame#Quick_Reference