Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to teleport someone in roblox?

I have three problems:

  1. I can't teleport players correctly, sometimes they still spawn in the original spawn point and would take several clicks before he teleports into the right one.

  2. Debounce won't work, you can still keep on teleporting.

  3. Error at line "player.Character.Torso.CFrame" expected CFrame, given Vector3.new("") value.

ClassHolder = script.Parent
ct = ClassHolder.CounterTerrorists
t = ClassHolder.Terrorists
ctspawn = game.Workspace.ctspawn --spawnpoint
tspawn = game.Workspace.tspawn --spawnpoint
Spectators = game.Workspace.Spectators
player = game.Players.LocalPlayer

Teamjoined = false

ct.MouseButton1Down:connect(function()
	if Teamjoined == false then
		player.TeamColor = BrickColor.new('Really blue')
		player.Character.Torso.CFrame = Vector3.new(ctspawn.Position.X,ctspawn.Position.Y + ctspawn.Size.Y / 2 + 7,ctspawn.Position.Z)--This line Error CFrame expected
		player:LoadCharacter()
		ClassHolder.Visible = false
		Teamjoined = true
	elseif Teamjoined == true then
		print('You already joined a team')
	end
end)	

t.MouseButton1Down:connect(function(t)
	if Teamjoined == false then
		player.TeamColor = BrickColor.new('Really red')
		player.Character.Torso.CFrame = Vector3.new(tspawn.Position.X,tspawn.Position.Y + tspawn.Size.Y / 2 + 7,tspawn.Position.Z)--This line Error CFrame expected
		player:LoadCharacter()
		ClassHolder.Visible = false
		Teamjoined = true
	elseif Teamjoined == true then
		print('You already joined a team')
	end
end)

2 answers

You attempted to put a Vector3 instead of a CFrame, but instead you should give a CFrame with a Vector3, like this:

player.Character.Torso.CFrame = CFrame.new(Vector3.new(ctspawn.Position.X,ctspawn.Position.Y + ctspawn.Size.Y / 2 + 7,ctspawn.Position.Z))

I hope this helped. ;)

2 comments

0

Error line at 14 and 26: Players.Player1.PlayerGui.ScreenGui.ClassHolder.LocalScript:26: attempt to call global 'CFrame' (a table value)

0

weird... It works when I try it...

Problem:

You can't teleport a player

Solution:

There is a method for a Character in Roblox called MoveTo, this is used when moving/teleporting a character.

player.Character:MoveTo(Vector3.new(teleport location))

Hope this helped , jmanrock123

1 comment

0

zdxdxdxdxd

This discussion is preserved as it was. New answers, comments, and votes are closed.