Getting The Players Own Gui

I want to make a variable wich = to the players playerGui, but i cannot get it to work I’ve tried this.

local player = game.Players.LocalPlayer
local npcDialogueFrame = player.PlayerGui.MainGui.NpcDialogueFrame

Can someone please help me with a solution?

server or local script?
chjarr

If it’s a LocalScript then your thing should work, but if it’s a Script then you’ll have to use a different way of getting the player, since you can’t get LocalPlayer on the server by just calling it. Try maybe using a .Touched event or a .PlayerAdded event?

Server Script:

game.Players.PlayerAdded:Connect(function(player)
local npcDialogueFrame = player.PlayerGui.MainGui.NpcDialogueFrame


end)

Local Script:

local player = game:GetService("Players").LocalPlayer
local npcDialogueFrame = player.PlayerGui.MainGui.NpcDialogueFrame

Try this

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.