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
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.
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!