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

How would I transfer leaderboard IntValues?

Asked by
Mystdar 352 Moderation Voter
9 years ago

Say I have a IntValue in another script because it is an Interger it can transfer through scripts (so I am told), how would I do that, please provide examples if need be! Thanks!

1 answer

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

First, it cannot pass data between scripts because it is an integer, but because it is an instance. An instance is basically a 'thing'. For example, a Part is an instance, a Script is an instance, a ScreenGui is an instance. You do not put an instance in the code of a script, but you can access it with the code. For example, let's say you have an IntValue in workspace.

Script1:

game.Workspace.IntValue.Value = 5

Script2:

wait(1)
if game.Workspace.IntValue.Value == 5 then
    print("It's 5")
end

Here, you can see that in one script we changed the int value, and in the other script we checked what value it was. Both scripts need the other in order to complete the task, and they both rely on the existence of an IntValue in workspace.

Another example is a GUI timer. It's very common to put an IntValue in workspace, then 1 script makes the int value count down from a number (100, for example), and the second script makes the GUI's text equal to that of the IntValue's value.

0
Thanks alot as a side note, how would you do that last bit, I have a rough idea from previous scripts but thanks! Mystdar 352 — 9y
0
To count down, look into for loops. To detect when the value changes, look into the Changed event. Then attempt some code and ask another question if you need help! Perci1 4988 — 9y
Ad

Answer this question