Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

My script says it's working, but doesn't make the GUI I chose visible?

I'm trying to make a simple chat command, a whitelisted player will be able to say "gui" and the GUI I chose should become visible. It will also say a message in console "GUI Script Working!" but it doesn't show the GUI, it only says the text in the console, does anyone know why this is happening? (I'm new to scripting sorry for the lack of knowledge.)

local isAdmin = {["Tantalingo"] = true} -- "Tantalingo" is my username
 
function findPlayer(name)
    for _, player in ipairs(game.Players:GetPlayers()) do
        if player.Name:lower() == name:lower() then
            return player
        end
    end
end
 
function onChatted(message, player)
    if message:sub(1, 5) == "gui" and isAdmin[player.Name] then
       game.StarterGui.AccessUI.Main.Visible = true
		print "GUI Script Working!"
        end
    end
 
game.Players.PlayerAdded:connect(function(player)
    player.Chatted:connect(function(message) onChatted(message, player) end)
end)

1 comment

0

Instead of "Visible", try with "Enabled".

1 answer

It is because you are changing StarterGui which is where GUI is stored and copied into a players PlayerGui when they join or respawn. To access a players gui you must be in a LocalScript and use:

game.Players.LocalPlayer.PlayerGui

5 comments

0

You don't have to be in a local script to access the players GUI's. You do however have to be in a local script to use LocalPlayer in order to access them.

0

"game.Players.LocalPlayer.PlayerGui.AccessUI.Main.Visible = True" Instead?

0

But could I just put the original script into the GUI and change it to "script.parent.parent.Main.Visible = True"?

0

@Tantalingo Sorry about the long response time. Yes that would work.

0

Click on the word PlayerGui in my post for more info on it

This discussion is preserved as it was. New answers, comments, and votes are closed.