01 | --Closes Gui |
02 | function onChatted(message, player) |
03 | if message = = "/Close" then |
04 | game.StarterGui.StatusGui.Status.Visible = false |
05 | else |
06 | game.StarterGui.StatusGui.Status.Visible = true |
07 | end |
08 | end |
09 |
10 | game.Players.PlayerAdded:connect( function (player) |
11 | player.Chatted:connect( function (message) onChatted(message, player) end ) |
12 | end ) |
I might have made an error somewhere but cant seem to find it. I used a similar script to kill the character but this one seems to not work. Is it not possible to use this method to close a Gui? What other options could be used?
You're using StarterGui
And so did everyone else, once upon a time
When you're changing something in StarterGui, the Player won't notice until they respawn. What you need to do instead is change it in the Player.PlayerGui
1 | function onChatted(message, player) |
2 | if message = = "/Close" then |
3 | player.PlayerGui.StatusGui.Status.Visible = false |
4 | else |
5 | player.PlayerGui.StatusGui.Status.Visible = true |
6 | end |
7 | end |
As a side note, your else
block probably won't work how you want it to, because that will make it reappear if the Player says anything else.
You're changing the Gui of a Player, not the StarterGui because that would show up for everyone(it would not work anyway).
PlayerGui instead of StarterGui