Hi! I’m unsure how to go forward with this code. The script in question is part of a larger settings menu GUI and unfortunately any time it’s ticked is not working in the slightest. I’m not very experienced when it comes to scripting and would appreciate any help at all. I’ve tried multiple solutions but unfortunately cannot seem to link the GUI setup and the script. Attached is a screenshot of the GUI setup and the code that is giving me trouble.
local Players = game.Players
local module = {}
module.ToggleNames = function(bool)
Hide = bool
for _, player in pairs(Players:GetPlayers()) do
if player.Character then
local head = player.Character:FindFirstChild("Head")
if head and head:FindFirstChild("NameGui") then
head.PlayerDisplay.Enabled = not Hide
end
end
end
end
module.ToggleName = function(char)
local head = char:FindFirstChild("Head")
if head then
local display = head:FindFirstChild("NameGui")
if display then
display.Enabled = not Hide
end
end
end
return module
I’m assuming the problem lies in the part of the script that finds the GUI itself but am stumped on how to rewrite it. Again, any help at all would be appreciated. Thanks!
Thank you for this! Unfortunately, though, I’m unable to group the two GUI parts together to make them turn off and on in time with each other. Here’s my altered script:
if player.Character then
local head = player.Character:FindFirstChild("Head")
if head and head:FindFirstChild("NameGui") then
head.NameGui.Enabled = not Hide
end
end
end
end
module.ToggleName = function(char)
local head = char:FindFirstChild("Head")
if head then
local display = head:FindFirstChild("NameGui")
if display then
display.Enabled = not Hide
And here’s what I attempted to edit it to which proved to not work:
module.ToggleNames = function(bool)
Hide = bool
for _, player in pairs(Players:GetPlayers()) do
if player.Character then
local head = player.Character:FindFirstChild("Head")
if head and head:FindFirstChild("NameGui","RankGui") then
head.NameGui.Enabled = not Hide
head.RankGui.Enabled = not Hide
end
end
end
end
module.ToggleName = function(char)
local head = char:FindFirstChild("Head")
if head then
local display = head:FindFirstChild("NameGui", "RankGui")
if display then
display.Enabled = not Hide
This is probably simply but it’s flying completely over my head. I appreciate your initial response!
Alright, your problem is the fact that you can not try to find 2 different children in the same :FindFirstChild().
module.ToggleNames = function(bool)
Hide = bool
for _, player in pairs(Players:GetPlayers()) do
if player.Character then
local head = player.Character:FindFirstChild("Head")
if head and head:FindFirstChild("NameGui") and head:FindFirstChild("RankGui") then
head.NameGui.Enabled = not Hide
head.RankGui.Enabled = not Hide
end
end
end
end
module.ToggleName = function(char)
local head = char:FindFirstChild("Head")
if head then
local display = head:FindFirstChild("NameGui")
local display2 = head:FindFirstChild("RankGui")
if display and display2 then
display.Enabled = not Hide
display2.Enabled = not Hide