Teleport :MoveTo Help

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    Better way to teleport player without glitching

  2. What is the issue? Include screenshots / videos if possible!
    The player glitches/teleports out, not to the part its suppose to

Gif of what happens>
Mahzu :stew: Restaurant (UnderDevelopment) - Roblox Studio (gyazo.com)

Anyone know a better method to teleporting players instead of :MoveTo to a part without glitching?

1 Like

Yes, I do. I would use:
Char:SetPrimaryPartCFrame()
EDIT: I’d say it’s one of the less used ways of teleporting, but it’s quite simple and doesn’t glitch much.

2 Likes

That may work, but you could also change the character’s HumanoidRootPart position to the position you want.

@thyswedishviking does the same thing.

Yes that will work equally well because that’s what it’s doing, it’s doing just that. As the primary part is the HumanoidRootPart.

2 Likes

Would you like a code example??

1 Like

Isn’t the PrimaryPart for a character model the HumanoidRootPart?

1 Like

Yeah, it is. I forgot about that.

2 Likes
script.Parent.ClickDetector.MouseClick:Connect(function(plr)
	plr.Character:SetPrimaryPartCFrame() -- Put where you want to teleport to in the parentheses.
end)

people can get stuck in a aprt

There’s a simple solution to that:

local _, ModY, __ = Character:GetModelSize() -- Gets the size of the player's character model
Character:SetPrimaryPartCFrame(NewCFrame + Vector3.new(0, ModY / 2, 0)) -- Set the new CFrame with an offset of half the player's character model size on the Y axis

Probably not the best solution, but it should prevent a player clipping into a part.

1 Like


Hey so I did the SetPrimaryPartCFrame method on the player and it works!

However, the glitch also happens when I do the :MoveTo with a model, so I made a primary part for it and used the setprimarypartcframe for it and it fixes the glitch, however, it doesn’t set it in the right position, or say its underneath where its supposed to be.

Is there a method to setprimarypartcframe that’ll make the model always be on top of the grill perfectly? (The black part)

You could try setting up a part akin to a SpawnLocation, and use the code I’d written with one change.

local _, ModY, __ = Character:GetModelSize()
Character:SetPrimaryPartCFrame(NewCFrame + Vector3.new(0, (ModY / 2) + (Part.Size.Y / 2), 0)) -- Add half the part's size on the Y axis as well

Not sure how to convert my code to that method

grillfood:SetPrimaryPartCFrame(CFrame.new(workspace.GrillAsset:FindFirstChild(grillname):FindFirstChild(station).MainPart.Position))
		

Is grillfood the player’s character? I don’t understand. Do you mind explaining what each variable is or sharing more code?

That’s what SetPrimaryPartCFrame does lol.

Just use CFrame manipulation.

i.e:

Character.PrimaryPart.CFrame = Goal.CFrame;

Hope I helped. Sorry if I’m not fully matching the criteria as to what you’re asking, I’m a bit confused, could you furthermore elaborate if so? Thanks! :grinning_face_with_smiling_eyes:

I never looked at the replies. :man_shrugging:

Player.CharacterAdded:Connect(function(Character)
Character:WaitForChild("HumanoidRootPart")
local _, ModY, __ = Character:GetModelSize()
local CFrameVar = workspace.GrillAsset.grillname.station.MainPart.CfFrame
grillfood:SetPrimaryPartCFrame(CFrameVar + Vector3.new(0, (ModY / 2) + (Part.Size.Y / 2), 0)) -- Add half the part's size on the Y axis as well
end)

That should work.

I feel that could be implemented better with a bit more info – even then, the FFC could be cut out, it would error either way.

1 Like

Alright edited it, and it should work. (Be sure to credit Storm on that because I used his code from his comment)

I’m not sure how your variables are set up, but this’s how I’d implement my code in a program:

local SpawnPart = game.Workspace.SpawnPart

...

Player.ChraacterAdded:Connect(function(Character)
    Character:WaitForChild("HumanoidRootPart")
    local _, ModY, __ = Character:GetModelSize()
    Character:SetPrimaryPartCFrame(SpawnPart.CFrame + Vector3.new(0, (ModY / 2) + (SpawnPart.Size.Y / 2)))
end)
1 Like