Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Player1 is not a valid member of players?

Asked by 7 years ago

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

Log in to vote
0
Answered by
H4X0MSYT 536 Moderation Voter
7 years ago

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.

Ad
Log in to vote
0
Answered by 7 years ago

change Player1 With LocalPlayer and it should work

Answer this question