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

Where are the IntValues being created?

Asked by
gecko95 20
9 years ago

Since I'm still a bit new to scripting, I don't know where these Values are being put when created.

function NewPlayer(Player)
    local Stats = Instance.new("IntValue",Player)
    Stats.Name = "leaderstats"

    local Laps = Instance.new("IntValue", Stats)
    Laps.Value = 0
    Laps.Name = "Laps"
0
The first one is being sent to the specified player. The second one is being sent to that IntValue. A value object within a value object. funyun 958 — 9y

2 answers

Log in to vote
1
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
9 years ago

The second argument of Instance.new (i.e, the second thing in the parentheses) will become the Parent of the object created. On line 2, an IntValue is getting created and put into the Player parameter of the function. What the parameter equals depends on what you're doing with the function, but that's where the IntValue will go.

Then, on line 5, another IntValue is created and put into Stats, which is the IntValue you created on line 2.

Ad
Log in to vote
0
Answered by 9 years ago

good question, I didn't understand how this worked for awhile. That code uses "Instance.new()" to insert an int value into a game. This is the setup: Instance.new(item being created , its parent)

In your case, it looks like the int value is being placed inside of player. I assume the like that connects to the function looks like: game.Players.PlayerAdded:connect(PlayerAdded)

"Player" in this case is player who just joined, the part of them that is found in game.Players.(player's name)

since the intvalue is placed inside the player there, it will look like: game.Players.(Player's name).leaderstats ---the next line changes its name to "leaderstats"

The next intvalue is placed inside stats which is the intvalue created right above.

To find these int values, you will have to start a test server with at least 1 player in studio mode and look in game.Players.Player1

Answer this question