so basically roblox has these things called NumberValues that hold numbers and NumberValues have an attribute called "Value" where the number is stored
totalCoins
is a NumberValue
totalCoins
has a value of 5
i want to print the value of totalcoins
in console so that 5
is printed
but how do i do it?
I'm a little confused on what you said but try:
print(totalCoins)
if not
print(totalCoins.Value)
Your answer is quite simple!
Firstly, you'll want to find a way to convert your value into something more feasible. There are several ways to do this, but I recommend first converting the number into a string. You can do so like this:
local tostr = tostring(totalCoins.Value)
So we now have a string variable that holds the value of totalCoins
. Our next course of action is to convert that variable into something more readable.
If we're using a LocalScript, I recommend utilizing gui objects for this.
local holder = Instance.new("ScreenGui", game.Players.LocalPlayer.PlayerGui) local textDisplay = Instance.new("TextLabel", holder) textDisplay.Text = tostr
Wonderful! Now we have the totalCoins
value correctly shown for the player to see.
At this point, the best course of action will be to ask the player very nicely to re-enter the code into a second textbox. We can do that using a few more simple guis:
local input = "" local button = Instance.new("TextButton", holder) button.Position = UDim2.new(0,0,0.3,0) button.Text = "Please enter the text from the TextLabel into the TextBox then click this TextButton!" local box = Instance.new("TextBox", holder) box.Position = UDim2.new(0,0,0.6,0) box.PlaceholderText = "Enter here!" button.MouseButton1Click:Connect(function() input = box.Text end)
And now, finally, the final step:
print(5)