I want to add an custom command inside of my game and make it so if they say “;openpanel” than the GUI would be enabled and by saying “;closepanel” than it would be disabled. How would I go about doing this, I’ve tried to do it but it did not work.
1 Like
localscript parented to the screengui
local UI = script.Parent
game:GetService("Players").LocalPlayer.Chatted:Connect(function(Str)
if (Str == ";openpanel") then
UI.Enabled = true
elseif (Str == ";closepanel") then
UI.Enabled = false
end
end)
1 Like
Thanks I will try that right now and let you know if it works.
It didn’t work, I don’t know why.
I really need to figure out how to do this, if you can help please reply to my post.
Player.Chatted does not work with TextChatService, which may be the reason why it isn’t working. If that’s the case you should use TextChatService.SendingMessage instead:
local TextChatService = game:GetService("TextChatService")
local UI = script.Parent
TextChatService.SendingMessage:Connect(function(TextChatMessage)
local Str = TextChatMessage.Text
if (Str == ";openpanel") then
UI.Enabled = true
elseif (Str == ";closepanel") then
UI.Enabled = false
end
end)
You can also use TextChatCommand for this.
1 Like
Thank you. If this works I will give you the solution, give me a few minutes.
1 Like
It worked, thank you so much.
1 Like
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.