JoeDev
|
  |
| Joined: 04 Oct 2011 |
| Total Posts: 6475 |
|
|
| 08 Aug 2017 09:34 AM |
script.Parent.Touched:connect(function() game.Players.LocalPlayer.PlayerGui.ScreenGui.Enabled = true wait(3) game.Players.LocalPlayer.PlayerGui.ScreenGui.Enabled = false end)
--This is a regular script that only works in studio. The dev console says it cannot locate LocalPlayer, so I ask you, what is the correct child name of Players in RobloxPlayer in this case? |
|
|
| Report Abuse |
|
|
Vezious
|
  |
| Joined: 09 Nov 2013 |
| Total Posts: 606 |
|
|
| 08 Aug 2017 09:40 AM |
| Are you using a local script? |
|
|
| Report Abuse |
|
|
JoeDev
|
  |
| Joined: 04 Oct 2011 |
| Total Posts: 6475 |
|
|
| 08 Aug 2017 09:45 AM |
| No, but its not supposed to be. |
|
|
| Report Abuse |
|
|
|
| 08 Aug 2017 09:47 AM |
How do you expect LocalPlayer to work when the Server doesn't have a player?
|
|
|
| Report Abuse |
|
|
Vezious
|
  |
| Joined: 09 Nov 2013 |
| Total Posts: 606 |
|
|
| 08 Aug 2017 09:48 AM |
Then LocalPlayer won't work.
Use Part and find the Character, then the Player.
script.Parent.Touched:connect(function(Part) local Character = Part.Parent local Player = game.Players:GetPlayerFromCharacter(Character) if Player then -- fill in the rest boi end end) |
|
|
| Report Abuse |
|
|
JoeDev
|
  |
| Joined: 04 Oct 2011 |
| Total Posts: 6475 |
|
|
| 08 Aug 2017 10:00 AM |
| It works, despite the fact that it says "Workspace.Part.Script:6: attempt to index local 'Player' (a nil value)" |
|
|
| Report Abuse |
|
|
JoeDev
|
  |
| Joined: 04 Oct 2011 |
| Total Posts: 6475 |
|
|
| 08 Aug 2017 10:07 AM |
| If I change the variable name, then the script doesn't work, why? |
|
|
| Report Abuse |
|
|
Vezious
|
  |
| Joined: 09 Nov 2013 |
| Total Posts: 606 |
|
|
| 08 Aug 2017 10:11 AM |
| Well that's why I put the 'if player'. That error shouldn't be happening. What variable? |
|
|
| Report Abuse |
|
|
JoeDev
|
  |
| Joined: 04 Oct 2011 |
| Total Posts: 6475 |
|
| |
|