Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to teleport someone in roblox?

Asked by 9 years ago

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.

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

  2. 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

Log in to vote
1
Answered by
sigve10 94
9 years ago

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. ;)

0
Error line at 14 and 26: Players.Player1.PlayerGui.ScreenGui.ClassHolder.LocalScript:26: attempt to call global 'CFrame' (a table value) hardhitsniper 30 — 9y
0
weird... It works when I try it... sigve10 94 — 9y
Ad
Log in to vote
0
Answered by
Azmidium 388 Moderation Voter
9 years ago

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

0
zdxdxdxdxd thehybrid576 294 — 7y

Answer this question