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)

1 comment
You're reinventing the wheel by indexing line 4's variable into line 5. Line 4 is, therefore, completely unnecessary.