Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Where are the IntValues being created?

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"

1 comment

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.

2 answers

✓ Accepted answer

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.

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

This discussion is preserved as it was. New answers, comments, and votes are closed.