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

How to make a hint admin command?

i want to know how to make a hint appear when someone says something. for example:

archmantella13: $hint Hello

and then a hint saying archmantella13: Hello appears. Here is what i have:

if string.sub(string.lower(msg),1,2) == "h/" then
text(speaker.Name .. ": " .. string.sub(msg,3),2,"Hint",game.Workspace)
end

2 comments

0

Your current code is pretty much perfect! Just make sure that the user prefixes their message with "$hint" and then make the hint

0

We'd need to see what the text function is. Assuming this is from an admin script from Free Models, just change "h/" to "$hint" and 1,2 to 1,5 and msg,3 to msg,6

2 answers

All you'd need to do is change "h/" to whatever you want to do for it to work.

1 comment

0

thx for making me learn the chat system, i was able to answer this guy's question because of it!

Put the following code in a ModuleScript inside of a Folder called "ChatModules" parented to Chat (do all of this pre-runtime). Inside of ChatModules, also have a BoolValue called "InsertDefaulModules" set to true.

local idsOfAdmins = {128498925, -1, 0, game.CreatorId} -- put the id of people you want to be admin
local currentHint
local hintDisplayed = false
local gui = Instance.new("ScreenGui")
gui.Name = "HintGui"
local hint = Instance.new("TextLabel")
hint.Name = "Hint"
hint.Visible = false
hint.Size = UDim2.new(1,0,0,25)
-- Don't change position
hint.BackgroundColor3 = Color3.new()
hint.BorderSizePixel = 0
hint.Font = Enum.Font.Legacy
hint.TextColor3 = Color3.new(1, 1, 1)
hint.TextScaled = true
local newGui
local newHint
local TextService = game:GetService("TextService")

local function Run(ChatService)
	local function filterMessage(message, speaker)
		local textResult = TextService:FilterStringAsync(message, speaker.UserId, Enum.TextFilterContext.PublicChat)
		local newMessage = textResult:GetNonChatStringForBroadcastAsync()
		return newMessage
	end
	local function hintCommand(speakerName, message, channelName)
		local isAdmin = true
		for i, v in ipairs(idsOfAdmins) do
			if game.Players[speakerName].UserId == v then
				isAdmin = true
				break
			end
		end
		if isAdmin and string.lower(string.sub(message, 1, 5)) == "$hint" then
			if not hintDisplayed then
				-- Create the hint
				-- First filter the hint's message
				local newMessage = filterMessage(speakerName..": "..(string.sub(message, 7, -1)), game.Players:FindFirstChild(speakerName))
				-- Then send it out
				newHint = hint:Clone()
				newHint.Text = newMessage
				newHint.Visible = true
				newGui = gui:Clone()
				for _, player in ipairs(game.Players:GetPlayers()) do
					local playerHint = newHint:Clone()
					local playerGui = newGui:Clone()
					playerGui.Parent = player.PlayerGui
					playerHint.Parent = playerGui
				end
				game.Players.PlayerAdded:Connect(function(player)
					player:WaitForChild("PlayerGui")
					local playerHint = newHint:Clone()
					local playerGui = newGui:Clone()
					playerGui.Parent = player.PlayerGui
					playerHint.Parent = playerGui
				end)
				hintDisplayed = true
			else
				local newMessage = filterMessage(speakerName..": "..(string.sub(message, 7, -1)), game.Players:FindFirstChild(speakerName))
				newHint.Text = newMessage
				for _, player in ipairs(game.Players:GetPlayers()) do
					player.PlayerGui.HintGui.Hint:Destroy()
					local playerHint = newHint:Clone()
					playerHint.Parent = player.PlayerGui.HintGui
				end
			end
			return true
		elseif not isAdmin and string.lower(string.sub(message, 1, 5)) == "$hint" then
			print("Not admin")
			-- You can put code here that does stuff like warn the player they are not admin
			return true
		else
			return false
		end
	end
	ChatService:RegisterProcessCommandsFunction("hint", hintCommand)
end

return Run

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