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

Player1 is not a valid member of players?

I have a piece of code and I keep getting an error that says** player1 is not a valid member of players. ** basically I'm using a function to make a wall appear when the button is touched. Here is the code: srry about how some of the code is not showing like the other 3 lines*

wall = script.Parent.Parent.wall

wall.Transparency = 1

wall.CanCollide = false

local function onTouch(Button) if (game.Players.Player1:FndFirstchild("Humanoid") ~= nil) then

	wall.Transparency = 0
	
	wall.CanCollide = true
	
end

end

script.Parent.Touched:connect(onTouch)

some extra information:

The script is held inside "Button"(which is the object I'm trying to touch to make the wall appear) wall is is inside workspace and is named "wall"

All help would be appreciated

2 answers

✓ Accepted answer

There is only ONE "Player1" in roblox. You should get the player from the part that hit. The part that hit your button could either be a limb, or accessory. Check before assuming where the players humanoid is located. "Button" is your argument for the .Touched event. This will be the part that touched the button.

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