✓ Accepted answer
Teleporting, eh? Your best bet for doing so is CFrame. (The MoveTo() method makes your character walk to the given location, so ignore any answers involving MoveTo().) Your script:
local core = game.Workspace.ExpansePortalStart
script.Parent.Touched:connect(function(hit)
if hit.Parent:FindFirstChild('Humanoid') then
hit.Parent.Head.CFrame = CFrame.new(core.Position)
end
end)
Two things I noticed here were that you were using the Character's Head to teleport and that you were using the undercase version of Connect(), which is basically useless at this point. For teleporting, it is recommended that you use the HumanoidRootPart's CFrame and not the Head's CFrame, As the name might give away, the HumanoidRootPart is your Character's only Part that is linked directly to the Humanoid, which means that teleportation would become a whole lot easier. (The HumanoidRootPart is also the Part you would use to script animations.) Scripting Helpers also recommends using Connect(), the successor to connect(). This is because the way you write code in Roblox involves more capitalization now than it did 6 years ago. These are just a few recommendations to follow, after all.
Here are other ways to teleport in Roblox (MoveTo() is not a teleportation method for obvious reasons):
That's all I know, and I hope you will heed attention on how to efficiently teleport Roblox players.
5 comments
CFrame, MoveTo (humanoid), MoveTo (Model), SetPrimaryPartCFrame, your way is most likely the most efficient besides not having a debounce in your touch function to limit the number of times it tries to change the CFrame when touched.
What do you mean by, "sometimes players are not teleported as they should be"?
use the HumanoidRootPart; it's better and is foolproof
You can use distance or Region3 to detect players near the part
summerequinox when a group of players enters an area, all of them are on the brick, after a certain amount of time the script is enabled and all payers standing on the brick are teleported, but sometimes one or more players do not teleport, that my main issue.