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

Why I can't change text with 2 values (Still not answered)?

Asked by 4 years ago
Edited 4 years ago

Please, look at the LocalScript where's Text =


-- Script ?1 RoundValue = game.ReplicatedStorage:WaitForChild("RoundValue") TimeValue = game.ReplicatedStorage:WaitForChild("TimeValue") function Intermission() while wait(1) do RoundValue.Value = "Intermission " TimeValue.Value = 30 TimeValue.Value = TimeValue.Value - 1 end end Intermission() -- LocalScript ?1 RoundValue.Changed:Connect(function() local Text = RoundValue.Value.. TimeValue.Value script.Parent.Text = Text end) TimeValue.Changed:Connect(function() local Text = RoundValue.Value.. TimeValue.Value script.Parent.Text = Text end)

3 answers

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Here is the actual answer. (It because you didn't provide enough information but whatever)

In "LocalScript", You make two same variables (local Text) inside the function which caused variables to get created when function triggered when you should create variable (local Text) above the function. You need to concatenate correctly and you need 2 variables for separated value (Int value and String Value).

You also need only 1 function connection because the script is read from top to bottom meaning only TimeValue.Changed will be ignored and you need to use the loop to update automatically unless you didn't want the loop so change While wait(0.25) do to Change Detection TimeValue.Changed:Connect(function()

This is the code if your value has 1 string value and 1 int value (only local script)

local Text = RoundValue.Value
local Time = TimeValue.Value

While wait(0.25) do -- change to (TimeValue.Changed:Connect(function() if you don't want the loop
    script.Parent.Text = Text..Time
end -- also add ) if you don't want the loop

Since you didn't ask for the script code so I only provide code for the local script.

In the future, you may need to concatenate and use variable correctly so you** should** read more on how variable and concatenate works so that you can face this error less.

If this answer helped then please accept this answer.

Ad
Log in to vote
0
Answered by 4 years ago

In the Intermission function, you set the TimeValue to 30, then minus one, every loop. Basically the value never changes because it is always set back to 30 :[

0
You will also need to 'break' your loop once it reaches 0, otherwise it will continue below 0 to -1, -2, -3 etc. darkelementallord 686 — 4y
0
I just question about ----> TEXT <--- and why I can't change it with 2 values, not about loop, not about breaking loop. I didn't said I don't need -1 -2 -3, I need this numbers. Please, help me with part of the script I said about. ArtemVoronin0 171 — 4y
Log in to vote
0
Answered by 4 years ago

I think the problem is that you need to convert the numbers into strings, because you cannot merge IntValues together. Before merging the two variables together, on separate lines convert them into strings and (optional) putting them in new variables (this bit's important) by wrapping them in a bracket and putting tostring before them, for example:

tostring(TimeValue)

If this didn't work, put .Value on the end of the variable name (I always forget if it works or not with tostring() ). By converting them into strings, you should be able to merge them using those new values (but make sure this time that when merging the strings you don't use .Value otherwise the computer doesn't like it and will spit out an error message). Tell me how it goes and if it works!

Answer this question