Help Teleporting a Player?
So this goes along with a question that I've previously asked (which has been answered). Here's the script again:
02 | character = game.Players:findFirstChild( "" ..game.Workspace.ValueHold.Player.Value.. "" ) |
05 | local t = game.Workspace.ValueHold.RoomCount |
07 | t.Changed:connect( function () |
08 | print ( "Changing Room..." ) |
09 | local r = math.random( 1 , 3 ) |
11 | local room = game.ServerStorage.defroom 1 :Clone() |
12 | room.Parent = game.Workspace |
13 | game.Workspace.ValueHold.CurrentRoom.Value = 1 |
14 | character.Character.Torso.CFrame = CFrame.new(game.Workspace.defroom 1. spawn.Position) |
16 | local room 2 = game.ServerStorage.defroom 2 :Clone() |
17 | room 2. Parent = game.Workspace |
18 | game.Workspace.ValueHold.CurrentRoom.Value = 2 |
19 | character.Character.Torso.CFrame = CFrame.new(game.Workspace.defroom 2. spawn.Position) |
21 | local room 3 = game.ServerStorage.defroom 3 :Clone() |
22 | room 3. Parent = game.Workspace |
23 | game.Workspace.ValueHold.CurrentRoom.Value = 3 |
24 | character.Character.Torso.CFrame = CFrame.new(game.Workspace.defroom 3. spawn.Position) |
Now, time for me to explain.
So, you touch a button, you get teleported to a new room, that room has a button that does the same thing, yadda yadda yadda, nothing important, until you get to the actual teleporting part. So, I have a value that stores the players name upon entering the game. So, if your name is "awesomedude123", then the value changes to "awesomedude123". The beginning of the script defines "character" as "awesomedude123", and when a random room is picked, it takes "character" and teleports him to a new room. Same story as my last problem: Works In test mode, but not in a server. I've been told to add a "wait(1)' before it, and that should fix the problem, but it doesn't.
All help is greatly appreciated.