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

PlayerGui isn't a valid member of part?

Asked by 10 years ago

I'm working on a strategy game called Solid. You find a secret door that leads to a deadly fire pit, but before you die, the screen turns black. But in the output it says...

21:45:02.089 - PlayerGui is not a valid member of Part 21:45:02.090 - Script 'Workspace.Teleporter.Script', Line 3 21:45:02.090 - Stack End

Here's the script.

script.Parent.Touched:connect(function(player)
    game.Workspace.ScarySound1:Play()
    player.PlayerGui.Gui.BlackScreen.Visible = true
end)

player.PlayerGui did work in a different script. (Not a localscript) Doing it the same way.

2 answers

Log in to vote
0
Answered by 10 years ago

Try doing it from the gui.

tp = workspace.Teleporter


tp.onTouched()
    game.Workspace.ScarySound1:Play()
    script.Parent.BlackScreen.Visible = true
end)

tp.Touched:connect(onTouched)

put that in a localscript under the BlackScreen imagelabel/frame.

0
I edited it a bit, and it worked. It didn't need to be under or in a localscript. Thanks bro. Grenaderade 525 — 10y
Ad
Log in to vote
-1
Answered by 10 years ago

PlayerGui is not in workspace so therefor can not be in line 3. But to do what you are trying to do you would have to go though Players.

0
player.PlayerGui not Workspace.PlayerGui Grenaderade 525 — 10y

Answer this question