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

Output says attempt to "index field 'LocalPlayer' (a nil value)" when trying to open Gui?

i'm making a Gui that pops up when you click on a brick.This is the script

script.Parent.MouseClick:Connect(function()
	game.Players.LocalPlayer.PlayerGui.talk.enabled = true
	
end)

1 comment

0

is it a localscript? localplayer can only be called from a localscript

2 answers

✓ Accepted answer

To make a script do something when a part is clicked, you need a ClickDetector. Also, you would make the gui invisible, then set it to visible (don't use ".Enabled" to make it appear).

Why you got the error you got: Scripts aren't the same as local scripts; you can only use "game.Players.LocalPlayer" on a local script.

1 comment

0

alright thanks

if that brick is in workspace,

game.Players.LocalPlayer

would not work so it should look something like this (not tested):

script.Parent.MouseClick:Connect(function(plr)
   plr:FindFirstChild("PlayerGui").talk.Enabled = true
end)

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