I am making a script where when a player click a button in a GUI it will change they're name color on a GUI to lime green. The color changing works when i manually put the command in and replace "Player" with my name. Please help.
It is saying this "Player is not a valid member of Frame"
local Button = script.Parent local VoteColors = game.StarterGui.AdminGUI.AGUI.Frame.Frame.PlayersComboBox local Player = game.Players.LocalPlayer.Name local PlayerVoted = game.Players.Player.PlayerGui.AdminGUI.AGUI.Frame.Frame.PlayersComboBox.List.Player Button.MouseButton1Click:Connect(function() print("WORKING") PlayerVoted.TextColor3 = Color3.new(0, 255, 0) end)
YOU MIGHT NEED TO CLICK "VIEW SOURCE" TO SEE CODE PROPERLY!
UPDATE: Here is the fixed code! (Thank you Claervoyance)
local Button = script.Parent local VoteColors = game.StarterGui.AdminGUI.AGUI.Frame.Frame.PlayersComboBox local Player = game.Players.LocalPlayer local PlayerVoted = game.Players[Player.Name].PlayerGui.AdminGUI.AGUI.Frame.Frame.PlayersComboBox.List[Player.Name] Button.MouseButton1Click:Connect(function() print("WORKING") PlayerVoted.TextColor3 = Color3.new(0, 255, 0) end)
It's trying to find your Player in the Frame. In order to index something in the Frame with the Player's name, you have to write the index as such: Frame[Player.Name]
Also, I took out the name from your Player variable. Just write Player.Name when you need to access the name.
So, here is (hopefully) corrected code:
local Button = script.Parent local VoteColors = game.StarterGui.AdminGUI.AGUI.Frame.Frame.PlayersComboBox local Player = game.Players.LocalPlayer local PlayerVoted = game.Players.Player.PlayerGui.AdminGUI.AGUI.Frame.Frame.PlayersComboBox.List[Player.Name] Button.MouseButton1Click:Connect(function() print("WORKING") PlayerVoted.TextColor3 = Color3.new(0, 255, 0) end)