|
| 17 Mar 2014 10:31 PM |
For some reason the PlayerAdded event within the script won't work (even after I added the line: repeat wait() until newPlayer). What coud be causing it not to load online? The script begins by calling the function LoadIntro() which is located at the bottom of the script.
--[[PLAYERADDED CHARACTER REMOVAL]]-- intro = game.Lighting.Intro main = game.StarterGui.Main spawningMachine1 = game.Workspace.SpawningMachine1 spawningMachine2 = game.Workspace.SpawningMachine2
game.Players.PlayerAdded:connect(function(newPlayer) repeat wait() until newPlayer
function LoadIntro() local newIntro = intro:Clone() newIntro.Parent = newPlayer.PlayerGui --print("A new intro was loaded for: "..newPlayer.Name) message = newIntro.Message wait(5) while not spacebarPressed do MessageAnimation() end end
function MessageAnimation() for i=1, 0, -0.1 do message.TextTransparency = i wait(0.1) end for i=0, 1, 0.1 do message.TextTransparency = i wait(0.1) end end
function SpawnCharacter() if spawningMachine1.NewSpawnPoint.SpawnedPlayer.Value == 0 then newPlayer.Character:MoveTo(spawningMachine1.NewSpawnPoint.Position) spawningMachine1.NewSpawnPoint.SpawnedPlayer.Value = 1 spawningMachine1.NewSpawnPoint.BrickColor = BrickColor.new("Bright green") spawningMachine1.Beam.BrickColor = BrickColor.new("Bright green") spawningMachine1.Beam.Rotation = Vector3.new(-90, 0, 0) elseif spawningMachine2.NewSpawnPoint.SpawnedPlayer.Value == 0 then newPlayer.Character:MoveTo(spawningMachine2.NewSpawnPoint.Position) spawningMachine2.NewSpawnPoint.SpawnedPlayer.Value = 1 spawningMachine2.NewSpawnPoint.BrickColor = BrickColor.new("Bright green") spawningMachine1.Beam.BrickColor = BrickColor.new("Bright green") spawningMachine1.Beam.Rotation = Vector3.new(-90, 0, 0) end end
function ConcludeIntro() message.Visible = false wait() for i=0, 1, 0.1 do newPlayer.PlayerGui.Intro.Screen.BackgroundTransparency = i wait() end newPlayer.PlayerGui.Intro:Destroy() end
mouse = newPlayer:GetMouse() spacebarPressed = false mouse.KeyDown:connect(function( key ) if not spacebarPressed then if key:byte() == 32 then spacebarPressed = true --A variable is set to: spacebarPressed converted from a boolean value to a string value. stringValue = tostring(spacebarPressed) print("spacebarPressed: "..stringValue) SpawnCharacter() print(newPlayer.Character.Name.." was spawned.") wait() ConcludeIntro() main.Disabled = false end end end)
repeat wait() until newPlayer:FindFirstChild("PlayerGui") if not newPlayer.PlayerGui:FindFirstChild("Intro") then LoadIntro() end end) |
|
|
| Report Abuse |
|
|
|
| 17 Mar 2014 10:36 PM |
PlayerGui isn't loaded until the character first spawns. I'm assuming you turned off CharacterAutoLoad, so ... yeah ... |
|
|
| Report Abuse |
|
|
|
| 17 Mar 2014 10:43 PM |
I actually have CharacterAutoLoads enabled. What would another option be? Should I add: repeat wait() until newPlayer.Character
before:
repeat wait() until newPlayer:FindFirstChild("PlayerGui") ?
|
|
|
| Report Abuse |
|
|
robocu3
|
  |
| Joined: 13 Mar 2009 |
| Total Posts: 6485 |
|
|
| 17 Mar 2014 10:49 PM |
didn't read the full script, assuming you don't already have it, have you considered "waitfordataready()"? -=Robo=- |
|
|
| Report Abuse |
|
|
|
| 17 Mar 2014 10:55 PM |
| @robocu3 No, I'm not even familiar with that. I want to stay relevant about fixing the PlayerAdded event to work online correctly please. |
|
|
| Report Abuse |
|
|
robocu3
|
  |
| Joined: 13 Mar 2009 |
| Total Posts: 6485 |
|
|
| 17 Mar 2014 10:56 PM |
wait for data ready waits for everything the player has to be loaded. it could potentially fix the problem. o.o -=Robo=- |
|
|
| Report Abuse |
|
|
|
| 17 Mar 2014 10:57 PM |
| Oh okay then. I'm willing to try it I just didn't want to stray to far from my familiarity. I apologize for my ignoring of your idea. |
|
|
| Report Abuse |
|
|
robocu3
|
  |
| Joined: 13 Mar 2009 |
| Total Posts: 6485 |
|
|
| 17 Mar 2014 10:59 PM |
Why not become familiar with it? cx it's a useful method http://wiki.roblox.com/index.php?title=WaitForDataReady_(Method) -=Robo=- |
|
|
| Report Abuse |
|
|
yurhomi10
|
  |
| Joined: 10 Dec 2008 |
| Total Posts: 13886 |
|
|
| 17 Mar 2014 10:59 PM |
| so :WaitForDataReady is just an easier way to instead call all those dataready's? |
|
|
| Report Abuse |
|
|
robocu3
|
  |
| Joined: 13 Mar 2009 |
| Total Posts: 6485 |
|
|
| 17 Mar 2014 11:00 PM |
If executed correctly, yes, I'm pretty sure. -=Robo=- |
|
|
| Report Abuse |
|
|
|
| 17 Mar 2014 11:01 PM |
| You're right robocu3. I'll study it and use it more often. Could you give me an example of how I could apply it correctly in my script? |
|
|
| Report Abuse |
|
|
yurhomi10
|
  |
| Joined: 10 Dec 2008 |
| Total Posts: 13886 |
|
|
| 17 Mar 2014 11:02 PM |
| newplayer:WaitForDataReady() |
|
|
| Report Abuse |
|
|
robocu3
|
  |
| Joined: 13 Mar 2009 |
| Total Posts: 6485 |
|
|
| 17 Mar 2014 11:04 PM |
--[[PLAYERADDED CHARACTER REMOVAL]]-- intro = game.Lighting.Intro main = game.StarterGui.Main spawningMachine1 = game.Workspace.SpawningMachine1 spawningMachine2 = game.Workspace.SpawningMachine2
game.Players.PlayerAdded:connect(function(newPlayer) newPlayer:WaitForDataReady()
function LoadIntro() local newIntro = intro:Clone() newIntro.Parent = newPlayer.PlayerGui --print("A new intro was loaded for: "..newPlayer.Name) message = newIntro.Message wait(5) while not spacebarPressed do MessageAnimation() end end
function MessageAnimation() for i=1, 0, -0.1 do message.TextTransparency = i wait(0.1) end for i=0, 1, 0.1 do message.TextTransparency = i wait(0.1) end end
function SpawnCharacter() if spawningMachine1.NewSpawnPoint.SpawnedPlayer.Value == 0 then newPlayer.Character:MoveTo(spawningMachine1.NewSpawnPoint.Position) spawningMachine1.NewSpawnPoint.SpawnedPlayer.Value = 1 spawningMachine1.NewSpawnPoint.BrickColor = BrickColor.new("Bright green") spawningMachine1.Beam.BrickColor = BrickColor.new("Bright green") spawningMachine1.Beam.Rotation = Vector3.new(-90, 0, 0) elseif spawningMachine2.NewSpawnPoint.SpawnedPlayer.Value == 0 then newPlayer.Character:MoveTo(spawningMachine2.NewSpawnPoint.Position) spawningMachine2.NewSpawnPoint.SpawnedPlayer.Value = 1 spawningMachine2.NewSpawnPoint.BrickColor = BrickColor.new("Bright green") spawningMachine1.Beam.BrickColor = BrickColor.new("Bright green") spawningMachine1.Beam.Rotation = Vector3.new(-90, 0, 0) end end
function ConcludeIntro() message.Visible = false wait() for i=0, 1, 0.1 do newPlayer.PlayerGui.Intro.Screen.BackgroundTransparency = i wait() end newPlayer.PlayerGui.Intro:Destroy() end
mouse = newPlayer:GetMouse() spacebarPressed = false mouse.KeyDown:connect(function( key ) if not spacebarPressed then if key:byte() == 32 then spacebarPressed = true --A variable is set to: spacebarPressed converted from a boolean value to a string value. stringValue = tostring(spacebarPressed) print("spacebarPressed: "..stringValue) SpawnCharacter() print(newPlayer.Character.Name.." was spawned.") wait() ConcludeIntro() main.Disabled = false end end end)
repeat wait() until newPlayer:FindFirstChild("PlayerGui") if not newPlayer.PlayerGui:FindFirstChild("Intro") then LoadIntro() end end)
^^could potentially solve a loading problem, i'm not sure, try it -=Robo=- |
|
|
| Report Abuse |
|
|
|
| 17 Mar 2014 11:05 PM |
You don't seem to be using any kind of Data Persistence in this script, so WaitForDataReady is useless to you.
Try throwing a newPlayer.CharacterAdded:wait() right after your repeat wait() until newPlayer line. |
|
|
| Report Abuse |
|
|
|
| 17 Mar 2014 11:06 PM |
| Thank you guys I'll try it out! |
|
|
| Report Abuse |
|
|
robocu3
|
  |
| Joined: 13 Mar 2009 |
| Total Posts: 6485 |
|
|
| 17 Mar 2014 11:07 PM |
@Agent I had come to the conclusion WaitForDataReady waited for everything it's being used on to be loaded, I wasn't told it was limited to Data Persistence and I have reason to believe it isn't. -=Robo=- |
|
|
| Report Abuse |
|
|
|
| 17 Mar 2014 11:08 PM |
| Oh and robocu3 please send a friend request to my account called itachi5036. It's my main account and I'd love to stay in touch with you about scripting. |
|
|
| Report Abuse |
|
|
robocu3
|
  |
| Joined: 13 Mar 2009 |
| Total Posts: 6485 |
|
| |
|
|
| 17 Mar 2014 11:09 PM |
| WaitForDataReady was specifically designed to halt your script until the Data Persistence 'API' is loaded. That is, the server fetches anything you've saved through Data Persistence (SaveString, SaveBool, SaveInstance, SaveNumber). WaitForDataReady has no connections with character spawning or loading the player into the game. |
|
|
| Report Abuse |
|
|
|
| 17 Mar 2014 11:12 PM |
That makes sense AgentFireFox. Oh and that line: newPlayer.CharacterAdded:wait() it didn't work.
In the script it looked like this at the top:
repeat wait() until newPlayer newPlayer.CharacterAdded:wait() |
|
|
| Report Abuse |
|
|
|
| 17 Mar 2014 11:15 PM |
| Use Test Server -> Test Player and see if you have any errors in your script. |
|
|
| Report Abuse |
|
|
|
| 17 Mar 2014 11:18 PM |
I went on Play Solo mode and it didn't work and there were no output errors.
|
|
|
| Report Abuse |
|
|
|
| 17 Mar 2014 11:19 PM |
You should use Test Server for PlayerAdded troubles. For some reason, errors don't like to show up in the Play Solo sometimes.
Are you getting the print statements when you Play Solo? |
|
|
| Report Abuse |
|
|
|
| 17 Mar 2014 11:26 PM |
| I just tested it on a Test Server and nothing showed up in output as well as the script didn't do what I needed it to do still. Also, I went on Play Solo mode previously and I got the same results. |
|
|
| Report Abuse |
|
|
|
| 17 Mar 2014 11:34 PM |
And you started a player during Test Server? Is this script disabled? Try adding print statements in your code after the definitions of your functions. Try disabling and re-enabling the script AS SOON AS you start the server (before adding the player).
This script shouldn't be breaking unless you have some hierarchy error. |
|
|
| Report Abuse |
|
|