In my script I want to have the Left Alt key change the lettering inside of a GUI. The script is a LocalScript located inside StarterPack. For some strange reason when I go to test it, the lettering doesn't change but instead says "Attempt to change a nil value" As you can see I'll be adding more code below that will change the leg used. I haven't added that code yet due to the fact that this simple thing isn't working, it's verryyy frustrating. Thanks for your help! EDIT: I have tested it with a different button than LeftAlt and still yields the same result.
CF = game.StarterGui.ChooseFoot.Frame.TextLabel game:GetService("UserInputService").InputBegan:connect(Pressed) function Pressed(key) if key == Enum.KeyCode.LeftAlt then if CF.Text == "R" then CF.Text = "L" elseif CF.Text == "L" then CF.Text = "R" end end end
You have your connection statement above the definition of the function - when the script reads the connection statement 'Pressed' is a nil value. Define the function BEFORE the connection statement.
local CF = game.StarterGui.ChooseFoot.Frame.TextLabel function Pressed(key) if key == Enum.KeyCode.LeftAlt then if CF.Text == "R" then CF.Text = "L" elseif CF.Text == "L" then CF.Text = "R" end end end game:GetService("UserInputService").InputBegan:connect(Pressed)
Your second problem is a very common one -- StarterGui is NOT what a player sees.
StarterGui is simply a container that stores GUIs
GUIs in StarterGui will be cloned into a Player's PlayerGui when they join and when they respawn -- this is why they are visible.
You only see what's in your PlayerGui.
GUIs in StarterGui are only visible in studio for editing purposes.
Therefore, when editing GUIs make your changes in a Player's PlayerGui. PlayerGui is, however, local, meaning if you want every player's GUIs to be edited you must loop through the players with a for loop and edit each GUI individually.