"Intermission" How to Visible Gui.?

Please help I’m making an Intermission game or a game like a minigame but I’m confused and the Gui where the player is teleported to the Gui maps won’t be seen Does anyone know this.?

local Players = game:GetService("Players")
local PlayerGui= game:GetService("PlayerGui")

local Players = PlayerGui:WaitForChild("AFKGui")


for i,player in pairs(game.Players:GetPlayers()) do
			local players = game:GetService("Players"):GetChildren()
			
			if players[i].afkMode.Value == true then
				
			else
				local character = player.Character or player.CharacterAdded:Wait()
				character:WaitForChild("HumanoidRootPart").CFrame = CurrentMap.SpawnPoint.CFrame 
				local players = game:GetService("Players"):GetChildren()
				Players.PlayerGui.AFKGui.AFK.Visible = false
				wait()
			end
		end

any help will. I am appreciated. :pray:

1 Like

Is it possible that afkMode is always true?

Otherwise if this is the actual script and it’s not inside a loop/other stuff then that should explain why it doesn’t work.

1 Like

so it should be ?

 Players.PlayerGui.AFKGui.AFK.Visible = false?

I see your mistake, you cant use two variables with the same name

In this case you used local Players = game:GetService(“Players”) at line 1.

And at line 4, you used local Players = PlayerGui:WaitForChild(“AFKGui”)
Try to rename it to PlayerAfkGui.

so it should be: local PlayerAfkGui = PlayerGui:WaitForChild(“AFKGui”)


Another mistake I see is that you are calling a service that doesn’t exist at line two.
local PlayerGui = game:GetService(“PlayerGui”)

It should be:

local PlayerGui = Players.PlayerName.PlayerGui

But there’s a problem, you cannot access the player GUI with a server script.
You may want to use remote events. You can learn more about remote events here

You can access the player GUI with a local script.

2 Likes

This should actually be local PlayerGui = Players[playerName].PlayerGui right?

1 Like

Oh yeah! Sorry a little mistake there, thanks!

1 Like

Hi! PlayerGui will never be a child of the Players Service, it is a child of each individual player which contains their Gui’s. Whilst I would not advise making any changes to a Gui from the server, you can technically do it.

local Players = game:GetService("Players")

for _,player in pairs(Players:GetPlayers()) do
    if not player.afkMode.Value then
        local character = player.Charater or player.CharacterAdded:Wait()
        character:WaitForChild("HumanoidRootPart").CFrame = CurrentMap.SpawnPoint.CFrame

        player.PlayerGui:WaitForChild("AFKGui").AFK.Visible = false
    end
end

As you can see, the code I changed simply references the Gui from the correct place. Hope this helps! Feel free to let me know if you have any further questions! :smiley:

1 Like

thank you for the help @lxuca and also the others thank you for your help. :smiley:

1 Like