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

Getting an error (attempt to index upvalue 'player' (a nil value))?

The line causing this error is

player:GetFullName().PlayerGui.Fade.Enabled = true

I've tried everything I could think of.

If you want to know what player is defined as, it's

local player = game.Players.LocalPlayer

This script is a normal script and not a LocalScript

1 answer

Hi there,

You are using a server script. Only local scripts can use local player = game.Players.LocalPlayer as this is client-sided. However, don't worry! You seem to be editing a Gui which lines up perfectly with using a local script. Guis together with using localplayer are both client-sided, thus, you should a local script instead. Here's how your script should look like:

In a local script, type out this code. If you are unable to parent this local script to gui that you have placed in starter gui use #1, else, use #2.

#1 Placing this local script separate from the gui.

--Gets the client(player) running this local script
local player = game.Players.LocalPlayer
--Get your Gui
local Gui = Player.PlayerGui.Fade

--Insert event that activates the gui (If you don't have one, ignore this)

--Enable the Gui
Gui.Enabled = true

#2 Place the local script as the child of the Gui

--Gets the client(player) running this local script
local player = game.Players.LocalPlayer
--Get your Gui
local Gui = script.Parent

--Insert event that activates the gui (If you don't have one, ignore this)

--Enable the Gui
Gui.Enabled = true

2 comments

0

Thank you so much for the help. Glad to see this community alive after the removal of the forums

0

No problem! Don't hesitate to ask a question on Scripting Helpers, everyone's very helpful here!

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