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

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

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

✓ Accepted answer

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

3 comments

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

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.

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

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.

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