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

Text label function (HELP?)

I am trying to make a slider that goes from 1 to 10 (for a voting system). When you slide the slider it outputs a huge number. all the way up is "5.1312805581556" and all the way down is "4.1333753849843". (its a mess) So basically if the text on the text label shows "5.1312805581556" then i want it to show "10". Here is my script because its not working.

"Data is the name of the text label"

local Value = script.Parent.Data.Text

local function Value()
	if Value("5.1312805581556")
	then 
		Value("10")
	
  end
end

local function Value()
	if Value == ("4.1333753849843")
	then
		Value = ("1")
	
  end
end

3 comments

0

What is the script in.is it in the label? If its in the text label it would just be local Value = script.Parent.Text just aksing so i can try to help

0

If you don't want nasty numbers like that, you can force a whole number using math.floor(), although the number would have to be rounded.

0

I recommend using whole numbers like he said ^ but to change the text label value just change the textlabel text, i don't understand why you wouldn't do that.

1 answer

✓ Accepted answer

You didn't fire the function, a function that placed on the script is not working, else you fire them.

Some function tips:

A function is a thing that defines a specific code that's sandwiched inside the function code.

Function benefit is:

Change the specific code easier if an error occurs.

Make this code at the last of the script:

while wait() do
	Value()
end

But that I have a problem that I don't know, does a function with the same name will fire at a same time that the code tell them to fire?

Fixing problems!

Maybe you should replace line 3 to 17 like this,

local function Value()
    if Value("5.1312805581556")
    then 
        Value("10")
	
	elseif Value == ("4.1333753849843")
    then
        Value = ("1")
  end
end

Hmmm... Looks something wrong...

Oh! It's the code!

The code line 2, see the problem?

Yeah, it's doesn't have double equals in it. And the code line 4 was not right, that have no equals so the value might not working!

Replace that code again:

local function Value()
    if Value == ("5.1312805581556")
    then 
        Value = ("10")
end
	
	elseif Value == ("4.1333753849843")
    then
        Value = ("1")
  end
end

Something seems not right too...

The full code is like this:

local function Value()
    if Value == ("5.1312805581556")
    then 
        Value("10")
	
	elseif Value == ("4.1333753849843")
    then
        Value = ("1")
  end
end

while wait() do
	Value()
end

It seems not right too!

If the value was 5.1312805581556, the Value will be 10.

If the value was 4.1333753849843, the Value will be 1.

But what will happen when the Value was not 5.1312805581556 or 4.1333753849843? The Value might kept the same value!

So we must fix this out,

The full code:

local function Value()
    if Value > ("5.1312805581556")
    then 
        Value("10")
	
	elseif Value < ("4.1333753849843")
    then
        Value = ("1")
  end
end

while wait() do
	Value()
end

I type so much for helping you out, hope I helped you, if the code was correct, then accept my answer! We'll appreciate much :)

I haven't test this on Roblox studio yet, so if the script was error then tell me! Ask me question if you have anything don't know too!

Bye!

5 comments

0

Hello, thank you for this information. I will test this as soon as I get up in the morning. As for the value between 5.1312805581556 or 4.1333753849843 I can't do it yet because I need to somehow add an increment system onto the slider so it will go in increments of 0.50, like 1.00, 1.50, 2.00 all the way to 10.00 but that's a task for tomorrow morning. So idk the exact number in those increments.

0

So if the number was 4 or lower, then it's was become 1; the number higher than 5, then it could be 10. The middle of the number was same like 4.5 it's not changing. If you have problems, message on this too or create a new question and post up the link to here, ill be happy to help.

0

I am using the script you gave me but i changed the less than and greater than to equal to. BUT i am getting an output but i guess the script does not see that output because its not changing the text label. I have it looking to the labels text in properties, but when i go in game and change it, and i look at the properties the "text" in the label don't really change, it only changes on screen.

0

So basically i need it so somehow see the number in output in order to change the text label. In output is shows a number like "5.1312805581556" So how do i make that script check output for that number? (Needs to be for each individual player, everyone will have there own number depending on what they put it to)

0

Equals to means if the number was 5.1312805581556 then it could be 10. If you printed or typed 5.1312805581556, onto output, then it could shows 10? I'm so bad in english sorry XD, but 

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