Ad
Log in to vote
0

This only changes the text one time but it should change it twice, can you help me?

Asked by 2 days ago

This script only changes the text once, even when the value changes it stays the same but the first time when the game starts it does change, can you help me fix this?

while true do script.Parent.Text = script.Parent.Parent.Parent.Value.Value end

2 answers

Log in to vote
0
Answered by 1 day ago
Edited 1 day ago
while wait(0.5) do -- with while true do it will change so fast so you cant see first text, now it is waiting 0.5 second 
    script.Parent.Text = script.Parent.Parent.Parent.Value.Value
end
Ad
Log in to vote
0
Answered by 1 day ago
Edited 1 day ago

First, to fix your code block, edit your question and click on the lua symbol at the top left corner, then put your code inside the tildes

Secondly, what are you trying to do?

And also you need to add a

wait()

in the script or else the loop will run 50 times a second and crash Roblox Studio.

And if you want the text to change twice, you can't do a while loop, you need a for loop. Example:

for i = 1, 2 do -- the 'i' can be whatever you want, it is just a varible.
-- Do stuff
end

But to finally answer your question, the reason the text isn't changing is because you aren't changing the text. You are just setting it to be the exact same value. You need to change something to the value and then set it to be the text.

If the value you're using is a number value then just do this:

for i = 1, 2 do

script.Parent.Text = script.Parent.Parent.Parent.Value.Value
script.Parent.Parent.Parent.Value.Value = script.Parent.Parent.Parent.Value.Value + 1
end

Or if it's something else like a string value then you can do this:

for i = 1, 2 do

script.Parent.Text = script.Parent.Parent.Parent.Value.Value
script.Parent.Parent.Parent.Value.Value = "WhateverYouWant"
end

Sorry for such a long answer, but you get the idea.

Answer this question