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

Connecting a value to a GUI text?

while true do
local player = game.Players.LocalPlayer
script.Parent.Text = player.ds:FindFirstChild("Cash").Value
end

What is wrong with this script?

1 comment

0

There are two problems: 1. You did not add a 'wait' to yield the 'while' loop to prevent it from firing the chunk infinitely on Execution, thus crashing the client. :P 2. Why is the Variable 'player' inside the 'while' loop? Why not put it outside of the loop? :)

3 answers

✓ Accepted answer

Problem:

Your most important function you are missing in your loop, is a wait function.

Why a Wait?

The reason why you need a Wait is because, a While loop with continue infinitely when executed, Without a wait, the Loop runs continuously, and crashes the client.


local player = game.Players.LocalPlayer

while wait() do
	script.Parent.Text = player.ds:FindFirstChild("Cash").Value
end

Additional Credits :

Validark

2 comments

0

There seems to be a problem with line 4

0

Nevermind, it worked as I resetted the character! Thanks all of you.

local player = game.Players.LocalPlayer
while true do
script.Parent.Text = player.ds:FindFirstChild("Cash").Value
wait() -- you made this an infinitive loop with no wait.
end

2 comments

0

Please put player variable outside of the loop.

0

trying to keep it as similar to his as i can but okay

while wait() do
local plr = script.Parent.Parent.Parent.Parent
script.Parent.Text = player.ds:FindFirstChild("Cash").Value
end

Now you don't need a LocalScript, use a regular script.

1 comment

0

If you see my reputation has gone down, two people downed it because of their misunderstanding...

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