generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: CharacterAdded teleport

Previous Thread :: Next Thread 
redlo43 is not online. redlo43
Joined: 16 Feb 2011
Total Posts: 4722
10 Nov 2013 12:42 PM
It doesn't do anything
no output
I'm trying to debug it

game.Players.PlayerAdded:connect(function(player)--Playeradded
player.CharacterAdded:connect(function(character)--Player who got added is respawned
Plyr = player
if _G.game then--global variable throughout whole game
if game.Workspace.map1 then --gamemodes
local ran = math.random(1,5)
if ran == 1 then
Plyr.Character.Torso.CFrame = CFrame.new(-89.809, 2.2, -325.854)
elseif ran == 2 then
Plyr.Character.Torso.CFrame = CFrame.new(-142, 16.4, -218)
elseif ran == 3 then
Plyr.Character.Torso.CFrame = CFrame.new(-240.146, 27.2, -322.146)
elseif ran == 4 then
Plyr.Character.Torso.CFrame = CFrame.new(-252, 77.6, -21)
else
Plyr.Character.Torso.CFrame = CFrame.new(2, 3.2, 7)
end

elseif game.Workspace.map2 then
local ran = math.random(1,4)
if ran == 1 then
Plyr.Character.Torso.CFrame = CFrame.new(49, 27.8, 41)
elseif ran == 2 then
Plyr.Character.Torso.CFrame = CFrame.new(-245, 32.6, 34)
elseif ran == 3 then
Plyr.Character.Torso.CFrame = CFrame.new(13, 7, -218)
elseif ran == 4 then
Plyr.Character.Torso.CFrame = CFrame.new(-37.868, 57, -247.632)
end
end
else
print 'game is not running!'
end
end)
end)
Report Abuse
redlo43 is not online. redlo43
Joined: 16 Feb 2011
Total Posts: 4722
10 Nov 2013 12:45 PM
I think it might be the player added part
but how else am I supposed to get players?
Report Abuse
MHebes is not online. MHebes
Joined: 04 Jan 2013
Total Posts: 2278
10 Nov 2013 12:46 PM
If you're trying to do this in Play Solo, you're going to have issues - The player will be loaded before the script runs.
Report Abuse
redlo43 is not online. redlo43
Joined: 16 Feb 2011
Total Posts: 4722
10 Nov 2013 12:48 PM
oh THANKS
Report Abuse
redlo43 is not online. redlo43
Joined: 16 Feb 2011
Total Posts: 4722
10 Nov 2013 12:53 PM
still doesn't work in play mode
Report Abuse
redlo43 is not online. redlo43
Joined: 16 Feb 2011
Total Posts: 4722
10 Nov 2013 12:53 PM
I spawn on a spawn in the lobby, but I don't teleport to one of the desired positions

I just stay in the lobby the whole time

Report Abuse
redlo43 is not online. redlo43
Joined: 16 Feb 2011
Total Posts: 4722
10 Nov 2013 01:06 PM
bump

scripting pros
Report Abuse
redlo43 is not online. redlo43
Joined: 16 Feb 2011
Total Posts: 4722
10 Nov 2013 01:08 PM
fixed it,
I am pro
Report Abuse
MHebes is not online. MHebes
Joined: 04 Jan 2013
Total Posts: 2278
10 Nov 2013 01:08 PM
1) You shouldn't have your global variable named 'game' or 'Game', seeing as that's already used by ROBLOX

2) Why do you have 'Plyr = player'? You're just making that variable global and causing issues later on. Delete that line and replace all your 'Plyr's with 'player', or just change the argument to 'Plyr'

3) 'if game.Workspace.map1 then' makes no sense. I think what you mean is this:
if Workspace:FindFirstChild("map1") then
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image