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

why the heck is this stupid textbox not detecting the input?

I am making a GUI settings interface, and I want to make it so that the user can change the background transparency. I made the script, and it said it had no errors, but the code did not work. I added a text button and added that. still not working. I added a print function that printed the text, I looked at the output, and no print with the value in the textbox. help. here is the stinking code:

local text = script.parent.Text
	script.Parent.Parent.TextButton.MouseButton1Click:Connect(function()
	script.Parent.Parent.parent.Frame.BackgroundTransparency = text
	script.Parent.Parent.parent.Frame3.BackgroundTransparency = text
	script.Parent.Parent.parent.Frame2.BackgroundTransparency = text
	print("this should have changed")
	print(text)
end)

2 answers

I am on phone so I can’t test it. Sry guys if I am incorrect If I understand correctly, the text is a number given by a player. First of all, text is a string but you need a number to change BackgroundTransparency. You need to convert it to a number by using tonumber([string]). Just replace text with tonumber(text) on line 3, 4 and 5. But before line 3 do a check if the given value cannot be converted into a number, it is important or else a script can crash. Just add

if tonumber(text) == nil then
 print(“the given value is not a number”)
else
 — the rest of the code
end

Hope this will help

This returned a nil value even though I inputted a number. The transparency changer also did not work.

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