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: No output?

Previous Thread :: Next Thread 
meteorit210 is not online. meteorit210
Joined: 08 Sep 2010
Total Posts: 348
15 Aug 2011 11:52 PM
Im trying to learn to make a LB and this is what I have so far


function onPlayerEntered(newplayer)

local stats = Instance.new("IntValue")
print("1")
stats.Name = "leaderstats"

while true do
print("2")
if newPlayer.Character ~= nil then break end
wait(5)
end

stats.Parent = newplayer

local kills = Instance.new("IntValue")
kills.Parent = leaderstats
kills.Name = "Kills"
kills.Value = 0
print("3")
end

game.Players.ChildAdded:connect(onPlayerEntered)

But the values arent even showing up inside player and im not getting any output
Report Abuse
ElectricBlaze is not online. ElectricBlaze
Joined: 18 Jul 2011
Total Posts: 22930
16 Aug 2011 12:00 AM
function onPlayerEntered(newplayer)

local stats = Instance.new("IntValue")
stats.Name = "leaderstats"
stats.Parent = newplayer

local kills = Instance.new("IntValue")
kills.Parent = stats
kills.Name = "Kills"
kills.Value = 0
end

game.Players.ChildAdded:connect(onPlayerEntered)
Report Abuse
swmaniac is not online. swmaniac
Joined: 28 Jun 2008
Total Posts: 15773
16 Aug 2011 12:01 AM
newPlayer.Character..

You defined newplayer.

CAPS SENSITIVE.

Although actually that should error, wonder why it doesn't.
Report Abuse
meteorit210 is not online. meteorit210
Joined: 08 Sep 2010
Total Posts: 348
16 Aug 2011 12:03 AM
still not working
Report Abuse
ElectricBlaze is not online. ElectricBlaze
Joined: 18 Jul 2011
Total Posts: 22930
16 Aug 2011 12:04 AM
Did you try mine?
Report Abuse
swmaniac is not online. swmaniac
Joined: 28 Jun 2008
Total Posts: 15773
16 Aug 2011 12:11 AM
I don't see a reason why it shouldn't.

Remove the while true do loop, there's no reason it needs to exist and I think it's what's causing your problem.

Regardless:

game:GetService("Players").PlayerAdded:connect(function(newPlayer)
Instance.new("IntValue", newPlayer).Name = "leaderstats"
Instance.new("IntValue", newPlayer.leaderstats).Name = "Kills"
end)

game:GetService("Players") is the same as game.Players, but it works if Players is renamed. GetService can be used on any service (services are the objects that are normally directly in game).

PlayerAdded is an event that fires when a Player joins the game, it's better than ChildAdded because ChildAdded could fire anytime something is put in Players.

In my script I didn't name my function, you don't need to name the function if you're going to use it once, when it's defined.

Instance.new() actually has 2 arguments, the class of the object you want to make and the parent you want to give it. In addition, if you don't need to assign the instanced value to a variable then you can set the name immeditally.
Report Abuse
meteorit210 is not online. meteorit210
Joined: 08 Sep 2010
Total Posts: 348
16 Aug 2011 12:23 AM
I tried everything but it still breaks and gives no output...
Does it work for you?
Report Abuse
epicfail22 is not online. epicfail22
Joined: 25 Sep 2009
Total Posts: 3739
16 Aug 2011 12:31 AM
@swmaniac Add newPlayer:WaitForDataReady at the beginning of your function and then it might work.
Report Abuse
swmaniac is not online. swmaniac
Joined: 28 Jun 2008
Total Posts: 15773
16 Aug 2011 12:36 AM
...
What?

It's not *using* data persistence. Why would it need to wait for the data?
Report Abuse
alexmach1 is not online. alexmach1
Joined: 02 May 2008
Total Posts: 1977
16 Aug 2011 01:29 AM
in the output, does it say "running (scriptnamehere)"?
Report Abuse
meteorit210 is not online. meteorit210
Joined: 08 Sep 2010
Total Posts: 348
16 Aug 2011 01:42 AM
yes
Report Abuse
Fredfishy is online. Fredfishy
Joined: 21 Mar 2009
Total Posts: 4197
16 Aug 2011 01:45 AM
You sure you aren't just testing this on Tools>Test>Play Solo?
:U
Report Abuse
meteorit210 is not online. meteorit210
Joined: 08 Sep 2010
Total Posts: 348
16 Aug 2011 02:44 AM
Thats where I test about everything...
but no it wont work online either
Report Abuse
meteorit210 is not online. meteorit210
Joined: 08 Sep 2010
Total Posts: 348
16 Aug 2011 09:34 AM
bump bump
Report Abuse
alexmach1 is not online. alexmach1
Joined: 02 May 2008
Total Posts: 1977
16 Aug 2011 09:48 AM
use tools>test>server
tools>test>start player

that enables output checking in online mode. changed event is buggy in solo mode, and in online you cant check output, so try that.
Report Abuse
epicfail22 is not online. epicfail22
Joined: 25 Sep 2009
Total Posts: 3739
16 Aug 2011 10:41 AM
@swmaniac; I have found that it needs a wait() at the beginning of leaderboards for some odd reason, and I have just been using :WaitForDataReady() and it seems to be working.
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