I am working on a script when you type in a number 1-18 in a button and you click a submit button, a gui will change color.
I typed in the script
script.Parent.MouseButton1Click:connect( function() for i = 1,18,1 do wait() if script.Parent.Parent.TableHandler.Text == i then game.Players.LocalPlayer.PlayerGui.TableFinder.TableLots["Table"..i].BackgroundColor3 = Color3.fromRGB(255,0,0) end end end)
and it ended up not working.
Could someone send me a script that would make this work?
OP first had to convert his text to a number so we're using tonumber() to convert that. We also changed the comparison to an if statement so we're only making one comparison compared to 18. After we ran this script, we got some errors so we looked in studio to see why it wasn't working and it turns out that the script was a regular script instead of a localscript so we couldn't access the local player. When we changed it to a local script it worked fine.
LocalPlayer = game.Players.LocalPlayer tableLots = script.Parent.Parent.Parent.TableLots script.Parent.MouseButton1Click:connect(function() local text = script.Parent.Parent.TableHandler.Text local number = tonumber(text) print("Number ", number) if number >= 1 and number <= 18 then local chosenTable = tableLots["Table"..tostring(number)] print("Table ", chosenTable) chosenTable.BackgroundColor3 = Color3.fromRGB(255,0,0) end end)