How can I make a list that appears in the chat whenever a player chats “!tools” and make it so only the player to chatted “!tools” can see the list of tools that are in the server storage?
You need to use Roblox’s Chat
service to detect when a player types “!tools” in the chat. When this happens, you’ll fetch the list of tools from the ServerStorage
. Then, you’ll send this list back to the player who typed “!tools”. This way, only the player who requested the list can see it. Remember, you’ll need to have some tools stored in your ServerStorage
for this to work. You can create a folder in ServerStorage
and put some tools inside it. This is the basic idea of what you need to do. You’ll need to write a script to implement this functionality.
Like I have this
local function displayToolNames(player)
local serverStorage = game:GetService("ServerStorage")
local tools = serverStorage:GetChildren()
local ToolsList = {}
for _, tool in pairs(tools) do
if tool:IsA("Tool") then
table.insert(ToolsList, tool.Name)
end
end
local toolListMessage = "Tools in ServerStorage: " .. table.concat(ToolsList)
game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage", {
Text = toolListMessage,
Color = Color3.new(1, 1, 1),
Font = Enum.Font.SourceSans,
FontSize = Enum.FontSize.Size18,
UserId = player.UserId,
})
end
game.ReplicatedStorage.Chatted.OnClientEvent:Connect(function(player)
displayToolNames(player)
end)
It does send the Message but doesn’t write the tools names.
why don’t you do this,
serverscript:
local myRemote = --your remote
local mytools = --your tools folder
game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
if msg ~= "!tools" then return end
local mystring = "Tools: "
for i,v in pairs(mytools:GetChildren()) do
mystring = mystring..v.Name.." "
end
myRemote:FireClient(plr)
end)
end)
localscript:
local myRemote = --your remote
local textchannel = game.TextChatService:WaitForChild("TextChannels"):WaitForChild("RBXGeneral")
myRemote.OnClientEvent:Connect(function(msg)
textchannel:DisplaySystemMessage(msg)
end)
The Local script doesn’t work. It has an error “Argument 1 missing or nil”
oh yeah, i did a tiny error, this is the working version:
--Change this line on server:
myRemote:FireClient(plr)
--to this:
myRemote:FireClient(plr,mystring)
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.