Teleport won't work

  1. What do you want to achieve? I want to achieve making a story game using Ponchoking’s YT tutorial.

  2. What is the issue? For some reason it won’t teleport me to the block.

  3. What solutions have you tried so far? I have not looked for solutions but I will if I cannot get a correct answer.

Scripts: Teleport won't work - #4 by AviatorLawsome

4 Likes

Can you just Copy and Paste the code in or we cant do anything.

Ok. 30 chars

function teleportPlayers(partCFrame)
	local players = game.Players:getChildren()
	for _,player in pairs(players) do
		if player.Character then
			if player.Character.HumanoidRootPart.Anchored == false then
				player.Character.Humanoid.Jump = true
			end
		end
	end
	wait(.5)
	for _,player in pairs(players) do
		if player.Character then
			if player.Character.HumanoidRootPart.Anchored == false then
				player.Character:SetPrimaryPartCFrame(partCFrame)
			end
		end
	end
end
TransitionEvent:FireAllClients()
	wait(3)
	teleportPlayers(game.Workspace.cafeteriaTeleport.CFrame)
2 Likes

They are in different parts of the main script.

Also, there is not a single script error.

I’ll reply when it comes to the transition.

Still won’t teleport me. 30chars

EDIT: I’m dumb lol

You never defined what player is? Maybe try doing that?

It teleports all players. 30chars

EDIT: i’m dumb lol waa
sorry man
ask someone else who doesn’t make my mistake lol

""

No, I mean you said:

local players = game.Players:getPlayers()

But never used “players”.
And instead used “player”.

Notice how you define what “players” is but never make use of “players”.
And instead you’re using “player”.
Note the “s”.

I used players in the script. 30chars

Wait, I don’t understand. 30chars

Yeah, I don’t think anyone else will come lol.

1 Like

Make it game.Players:GetPlayers()

Also, don’t make the first G small, its capitalised.

SetPrimaryPartCFrame() – Just needs a Part, not a CFrame value

so just make it

teleportPlayers(game.Workspace.cafeteriaTeleport)

Hope that helps!

1 Like

Still didn’t teleport me. 30chars

You should be using teleportationservice here if you want to teleport to different areas in the server, you said you want to be teleported to the block so what I would do is make the block the spawn and do:

local TS = game:GetService('TeleportService')

Ts:TeleportToSpawnByName(1818,"TeleportSpawn", player)

1818 is the placeID (I think this is optional)
“TeleportSpawn” is the name of the spawn
player is the player that will be teleported

Thats a little example there, you can get a documentation here

Also, don’t try teleporting in Roblox Studio as it doesn’t work there, teleport in the actual Roblox game.

However, for a story game you would need to read here

You would need to use TeleportService:TeleportAsync() to grab players to another server.

2 Likes

So, this is the script:

local Players = game:GetService("Players")
local TeleportService = game:GetService("TeleportService")
 
local placeId = 0 -- replace
local playerList = Players:GetPlayers()
 
local success, result = pcall(function()
    return TeleportService:TeleportPartyAsync(placeId, playerList)
end)
 
if success then
    local jobId = result
    print("Players teleported to "..jobId)
else
    warn(result)
end

With

local placeId = 0 – replace

How would I change that to teleport to a part?

3 Likes

This is teleport players to another game? Right?

No, this is teleporting to a part.

1 Like