local TextBoxID = MainGui.TextBox.Text
TextButton.MouseButton1Up:Connect(function()
local UsernameWeb = "https://api.rprxy.xyz/users/"..TextBoxID
My current code ^
User inputs a userid into the textbox then presses textbutton, the script proceeds to get the username (among other things) from the roblox API.
I know what I am doing, just don’t know the correct syntaxing, I’ve tried brackets etc. too.
local TextBoxID = MainGui.TextBox.Text
TextButton.MouseButton1Click:Connect(function()
local UsernameWeb = "https://api.rprxy.xyz/users/".. tostring(TextBoxID)
--do some stuff
end)
When you define the TextBox’s text as the variable your getting the text that is currently in the TextBox, instead you need to get the text whenever the button is pressed:
TextButton.MouseButton1Up:Connect(function()
local TextBoxID = MainGui.TextBox.Text
local UsernameWeb = "https://api.rprxy.xyz/users/"..TextBoxID
TextButton.MouseButton1Up:Connect(function()
local TextBoxID = MainGui.TextBox.Text
local UsernameWeb = "https://api.rprxy.xyz/users/".. tostring(TextBoxID)
local function printUsername()
local response
local data
pcall(function()
response = HttpService:GetAsync(UsernameWeb)
data = HttpService:JSONDecode(response)
end)
if not data then return false end
if data.Id == (TextBoxID) then
print(data.Username)
end
*end)*
Getting the error where indicated.
'Expected identifier when parsing expression, got ‘)’
TextButton.MouseButton1Up:Connect(function()
local TextBoxID = MainGui.TextBox.Text
local UsernameWeb = "https://api.rprxy.xyz/users/".. tostring(TextBoxID)
local function printUsername()
local response
local data
pcall(function()
response = HttpService:GetAsync(UsernameWeb)
data = HttpService:JSONDecode(response)
end)
if not data then return false end
if data.Id == (TextBoxID) then
print(data.Username)
end
end -- this closes the printUsername function
*end)*