game.Workspace.sFX.TimeHasBegunToMoveAgain:Play() game.Players.LocalPlayer.PlayerGui.THBTMA.Enabled = true wait (3) game.Players.LocalPlayer.PlayerGui.THBTMA.Enabled = false
I need help.
The Attempt to index with
exception refers to the trailing Instance, not the Instance of query. Therefore, there is an issue with the Player; the only scenario where LocalPlayer
would be invalid is a ServerScript.
It is a common mistake many beginners make, as they're unaware of basic networking logic. A Server, is a mainframe that manages multitudes of Clients, and is not a Client itself. The LocalPlayer
refers to the Player Object affiliated with the local machine; as aforementioned, a Server isn't a connected user, which is why we cannot allocate a Player Object from it.
The primitive difference between a LocalScript
and a Script
, is that each variation of the program is designed to run on it's respective end... LocalScripts
will be ran via the ROBLOX Player on the user's device, whilst a Script
will be ran on the ROBLOX Server.
This is why we can denote a Player Object through a LocalScript
, as the program resides within the local machine
Though, we can still achieve your goal, just through a different approach. A Sever can still understand what Clients are connected, and what are connecting. We can catch a connecting user through the .PlayerAdded signal of the Players
Service. From here, we can modify their User Interface:
local Players = game:GetService("Players") local function EnablePlayerGui(Player) local PlayerGui = Player:WaitForChild("PlayerGui") local THBTMA = PlayerGui:WaitForChild("THBTMA") THBTMA.Enabled = true end Players.PlayerAdded:Connect(EnablePlayerGui)
You need to use :WaitForChild()
in order to make the script wait for the PlayerGui object to be created on the player
game.Workspace.sFX.TimeHasBegunToMoveAgain:Play() game.Players.LocalPlayer:WaitForChild('PlayerGui').THBTMA.Enabled = true wait (3) game.Players.LocalPlayer:WaitForChild('PlayerGui').THBTMA.Enabled = false