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

Why doesn't my script update a text label according to a string value?

Asked by 5 years ago

Hey. I have a part that moves a model from replicated storage to workspace. The model has a part that should change a String Value when clicked and it does but for some reason the script that should update a text label's text doesn't work. Here's the code:

local case = game.Workspace:WaitForChild(script.Parent.Parent.CasesGui.Case.Value)
local deduction = case:WaitForChild("Deduction").Value

while true do
    wait()
    if case and deduction then
        if deduction == "Identification" then
        script.Parent.TextLabel.Text = "This is definetly a broken part from the stolen server"
        script.Parent.TextLabel.TextColor3 = Color3.new(234, 255, 0)
        elseif deduction == "Type" then
            script.Parent.TextLabel.Text = "From the bending and the feeling of this... This is Aluminum"
        end
    end
end

2 answers

Log in to vote
1
Answered by
DevingDev 346 Moderation Voter
5 years ago
Edited 5 years ago

You shouldn't write Value in a variable do it like this and see if it works.

local case = game.Workspace:WaitForChild(script.Parent.Parent.CasesGui.Case)
local deduction = case:WaitForChild("Deduction")

while true do
    wait()
    if case.Value and deduction.Value then
        if deduction.Value == "Identification" then
        script.Parent.TextLabel.Text = "This is definetly a broken part from the stolen server"
        script.Parent.TextLabel.TextColor3 = Color3.new(234, 255, 0)
        elseif deduction.Value == "Type" then
            script.Parent.TextLabel.Text = "From the bending and the feeling of this... This is Aluminum"
        end
    end
end
0
Its true, as much as it pains me its true, for some reason you can't give a value directly a variable you need to access it through or with its parent/Property Holder Omega_bs 40 — 5y
0
Unfortunately it doesn't. And for some reason I get "Infinite yield possible on 'Workspace:WaitForChild("Instance")" not having anything named Instance in the workspace or code. bruceywayne 35 — 5y
0
I accepted this answer because I can't accept my own and if someone else has this problem they can find the fix here bruceywayne 35 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

Update on this. I made this FE so I couldn't just update the Text from a normal script. I had to do it from the local script that defines what the event does when it's triggered.

Answer this question