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

Anyway to change StringValue based on TextLabel's text?

Hello there, I have a LocalScript where if a player presses a button the StringValue copies the current Text of the TextLabel, however it does not seem to work with any methods I could scavenge inside my head, what should I do?

NOTE: I used StringValue instead of IntValue for a specific reason

local user = game:GetService("Players").LocalPlayer
local button = user.PlayerGui.Roll.TextButton
local label = user.PlayerGui.Roll.TextLabel
local mainValue = user.PlayerGui.Roll.Value


button.MouseButton1Click:Connect(function()
	label.LocalScript.Disabled = true
	wait(1)
	if label.Text == "1" then
		mainValue.Value = "One"
	elseif label.Text == "2" then
		mainValue.Value = "Two"
	elseif label.Text == "3" then
		mainValue.Value = "Three"
	elseif label.Text == "4" then
		mainValue.Value = "Four"
	elseif label.Text == "5" then
		mainValue.Value = "Five"
	elseif label.Text == "6" then
		mainValue.Value = "Six"
	end
	label.LocalScript.Disabled = false
end)

2 comments

0

what errors are u getting? are u sure disabling the local script isnt effecting ur script?

0

Even when I remove the line where the localscript disables it still doesn't work

2 answers

It's not working because you are calling mainValue.Value.Value; mainValue is the Value itself.

Do mainValue = "One" instead of mainValue.Value = "One".

1 comment

0

Still not working

Be sure to use the output to check for errors, your new code should look like this:

local user = game:GetService("Players").LocalPlayer
local button = user.PlayerGui.Roll.TextButton
local label = user.PlayerGui.Roll.TextLabel
local mainValue = user.PlayerGui.Roll


button.MouseButton1Click:Connect(function()
    label.LocalScript.Disabled = true
    wait(1)
    if label.Text == "1" then
        mainValue.Value = "One"
    elseif label.Text == "2" then
        mainValue.Value = "Two"
    elseif label.Text == "3" then
        mainValue.Value = "Three"
    elseif label.Text == "4" then
        mainValue.Value = "Four"
    elseif label.Text == "5" then
        mainValue.Value = "Five"
    elseif label.Text == "6" then
        mainValue.Value = "Six"
    end
    label.LocalScript.Disabled = false
end)

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