Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Player is not a valid member of frame?

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

0

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

1 answer

✓ Accepted answer

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)

3 comments

0

Click view source to see it all.

0

This answer is EXACTLY what i was looking for. However your code is wrong in one area, i learned from you when you put [Player.Name] and that helped me fix one area. You put "game.Players.Player.PlayerGUI" at the begining, it needed to be "game.Players[Player.Name].PlayerGUI" THANK YOU!

0

Oh, glad you figured it out.

This discussion is preserved as it was. New answers, comments, and votes are closed.