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

use chat command to open a gui?

A script can with a command in chat open a gui?

1 answer

What you need to do is attach a player.Chatted event connection to every player that joins the game, and every time they chat, detect what they said and if they said your command then clone the gui into their PlayerGui.

Place this in ServerScriptService (and put the gui under the script):

--// Services

local Players = game:GetService("Players")

--// Variables

local prefix = "!" -- Change this to the prefix you want
local command = "gui" -- Change this to the after-prefix

local gui = script:FindFirstChildWhichIsA("ScreenGui")

--// Script

local function playerAdded(plr) -- function to run when player joins
	plr.Chatted:Connect(function(message, to)
		if message:sub(1, #prefix):lower() ~= prefix then return end
		-- above checks if the message had prefix
		
		if plr.PlayerGui:FindFirstChild(gui.Name) then return end
		-- above checks if the player already has the gui
		
		message = message:sub(#prefix + 1)
		if message ~= command then return end -- Check if equal to command
		gui:Clone().Parent = plr.PlayerGui
	end)
end

Players.PlayerAdded:Connect(playerAdded)

2 comments

0

this didn't work

0

You probably entered in something incorrectly or put the script into the wrong service, make sure to follow the instructions strictly.

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