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)
It's not working because you are calling
mainValue.Value
.Value; mainValue is the Value itself.
Do mainValue = "One"
instead of mainValue.Value = "One"
.
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)