So for my game, I’m trying to make a lobby, and have players teleport into the place and start the game there.
I am a builder and I’m not good at scripting, I have tried changing some of the words but nothing has worked. I tried testing it in-game and nothing happened. If anyone has any ideas of how to make it work I would greatly appreciate it.
Are you trying to move a player to a location or are you trying something with Roblox universe system?
For moving player characters, refer to the character by using the Players
service and find each and one of the players’ characters to the specific Vector3
. The Vector3
is a 3D position represented by XYZ, left and right, up and down, front and back relative to global space. One of the methods involves the use of CFrame
, moving the characters’ whole model or their “root” part.
Teleport service is to teleport people to different games, if you want to teleport the player somewhere, you want to set the cframe of their humanoid root part, or you can tween them there. Otherwise you teleport a player to a different game with teleport service.
You are using TeleportService incorrectly. That will teleport between places, not player location.
To move players, you can use PlayerModel:SetPrimaryPartCFrame(CFrame.new(target_position))
, where PlayerModel
is the model of the player, and target_position
is the Vector3
of the position where you want the characters to go to.
I am confused, do you want the player to click a button to teleport or just when the loading gui hits 0?
I’m trying to move them to a location
That script is not to move player, that script teleports a player from one game to another game.
TeleportService doesn’t move players, it teleports players to another game.
ok thank you
I’m just trying to teleport someone in general, and then I’ll get to someone touching someone and touching something and teleporting. I’m trying to learn how it works before I get to more complicated stuff
Here is a teleport function I wrote that might help with this:
-- player is the Player object of the player you want to teleport and target is a Vector3 of where you want to teleport the player to.
function Teleport(player, target)
player.Character:SetPrimaryPartCFrame(CFrame.new(target))
end
-- For example, I would use it like such:
local Players = game:GetService("Players")
Teleport(Players:FindFirstChild("Quackers337"), Vector3.new(20, 4, 50))
-- Alternatively, if you want them to teleport when touching a part to a different part
TeleportPart = game.Workspace.TeleportPart
TargetPart = game.Workspace.TeleportTarget
TeleportPart.Touched:Connect(function(other)
if other.Parent:FindFirstChild("Humanoid") then
local player = Players:GetPlayerFromCharacter(other.Parent)
Teleport(player, TargetPart.Position)
end
end)