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

Gui text not changing to value?

Asked by 7 years ago
Edited 7 years ago

This code isnt working for some reason. No error. its supposed to change the text of a gui to the value of a string value every time the value is changed.

local Status = script.Parent.Status
local Player = script.Parent.Parent.Parent.Parent
local StatusVal = game.Workspace.GameV2.Status.Value

while true do
    Status.Text = StatusVal
end)

2 answers

Log in to vote
0
Answered by
guiraz 25
7 years ago

As Rexbit said, you neep a wait in your loop and i also think you should have a >WaitForChild("")< so that it works online. Hope I helped

local Status = script.Parent:WaitForChild("Status")
local Player = script.Parent.Parent.Parent.Parent
local StatusVal = game.Workspace.GameV2.Status

StatusVal.Changed:connect(function(value)
    Status.Text = value
end)

Ad
Log in to vote
0
Answered by
rexbit 707 Moderation Voter
7 years ago

In loops, a wait is always needed, otherwise the studio will crash. Another point-out, a loop continues looping, never to stop unless broken up by a break, thus preventing the loop to update it's current code within.

local Status = script.Parent.Status
local Player = script.Parent.Parent.Parent.Parent
local StatusVal = game.Workspace.GameV2.Status

StatusVal.Value.Changed:connect(function(value)
    Status.Text = value
end)

Answer this question