Problem with Player Teleportation

I am creating a studio project where the player has to know a code to proceed. I do this using ScreenGuis. The thing is, when I enter the code, the player teleports, but they become invisible and move in a very weird way.


That’s strange, because when I look at it from server view, the player is visible.
image
Here is the script I wrote inside of the TextBox: I used a LocalScript, which might be the problem, but I am unsure how to do this using a regular script.

script.Parent.FocusLost:Connect(function()
	if script.Parent.Text == "Test Code" then
		game.Players.LocalPlayer.Character.HumanoidRootPart.Position = workspace.Teleport.Position
        --Teleport is the part the player teleports to.
		script.Parent.Parent.Visible = false
	end
end)

What am I doing wrong?

1 Like

Try moving the HumanoidRootPart’s CFrame to move between places instead of a Vector3 if that doesn’t work then maybe because the character is unable to go inside the block, maybe try setting the can collide property to false maybe?

Also, do you know that you are teleporting the player through the client side and not the server because it will only show your player moving so do it server sided.

this post is wrong, moving via cframe might work but at that point just use character:MoveTo()
setting position on the clientside is fine because it replicates and other players will see it, though if you want to add teleport checks for exploiting or other stuff later, then I’d advise moving it to the server side

2 Likes

You mean Humanoid:MoveTo() because :MoveTo() is a function of Humanoid, also I did not know that moving the character client sided will replicate to the server is there any way you could avoid that from happening?

i said character moveto not humanoid moveto… Model:MoveTo()
you probably can’t avoid replication to the server or at least not in any way that I know of, will probably break some stuff too
" Moves the Model.PrimaryPart to the given position."
PrimaryPart of a character is usually HumanoidRootPart, so this is cleaner

1 Like

Oh my bad Model:MoveTo() exists too.

1 Like

Maybe it’s something to do with the part, like I said before try setting the CanCollide property to false and see what happens.

When you teleport a player, you would use the CFrame property and not Position. Give this a read: CFrames | Documentation - Roblox Creator Hub

2 Likes

It’s already set to false, it’s probably because I used Position instead of :MoveTo().

(@Tamzy3D @Robin5D) Edit: :MoveTo() does not work because I want the player to teleport to an area that is otherwise inaccessible.

Yes, using a LocalScript will not teleport the player. Instead, use remote events to teleport the player from a LocalScript. You can check tutorials on YouTube. Your script is right also, but the only problem is you need to teleport from a Script.

I legit said that you should rather set the position on the server rather than the client but @Robin5D believes it replicates even though it does not, so yes like I said earlier teleporting client side won’t work.

wrong, it does teleport the player. thats why exploiters can teleport and it replicates

No, his idea fixed it. I think using a LocalScript was the problem.