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

Teleporting Players on Spawn?

Asked by 9 years ago

So, I wanted to be able to spawn a player in a custom location without having to use a spawn part. So I tried to make it so that when your character spawns in you are teleported to a specefic CFrame. Which I did so using this:

game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
        local humanoid = character:FindFirstChild("Humanoid")
        character.Torso.CFrame=CFrame.new(0,50,0)+findBaseOf(player).Position
        if humanoid then
            humanoid.Died:connect(function()
                wait(2)
                character:Destroy()
                wait(1)
                player:LoadCharacter()
            end)
        end
    end)
    player:LoadCharacter()
end)

After trying that I got an error saying "attempt to index a nil value". So I figured the torso hadn't loaded into the character yet and I replaced the teleporting line(The line with the error) with this:

character:WaitForChild("Torso").CFrame=CFrame.new(0,50,0)+findBaseOf(player).Position

This however did not help and it still returned the same message. So my question is, how do you go about spawning players into a specific location or teleporting them when they spawn without getting that error?

0
Please define what `findBaseof` is. woodengop 1134 — 9y
0
All you need to know is that it returns a part that is in workspace. Prohibetur 70 — 9y
0
can you post the full error message? There should be a line on which the error was encountered.. ImageLabel 1541 — 9y
0
11:49:27.942 - Workspace.PlayerHandler:33: attempt to index a nil value Prohibetur 70 — 9y
View all comments (3 more)
0
I don't see how that helped though ImageLabel Prohibetur 70 — 9y
0
Well line 33 is obviously not in the snippet you've provided so let us know exactly what the equivalent of line 33 is .... ImageLabel 1541 — 9y
0
Line 33 is in the snippet ... It's just not labeled as line 33. In the original question I said "I replaced the teleporting line(The line with the error)" though ... Prohibetur 70 — 9y

2 answers

Log in to vote
0
Answered by 9 years ago
--That might be impossible. You can't really CFrame something then place a script for you to teleport to there when you spawn. --Use a regular spawn point.
0
You can teleport users by setting their torso's CFrame very easily ... http://wiki.roblox.com/index.php?title=Teleportation Prohibetur 70 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

It looks to me like either the function "findBaseOf()" is returning nil or the ".Position" value, of whatever "findBaseOf()" is returning, is nil. I could give better input if you told me exactly what "findBaseOf()" is and what it consists of. I have to give this comment as an answer because I can't comment on any of the posts.

Answer this question