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

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

Asked by 2 years ago

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

Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

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

Ad
Log in to vote
0
Answered by 2 years ago

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

Answer this question