You can write your topic however you want, but you need to answer these questions:
Chat Commands that cause a Local message (in chat) called by a script.
I need a command to know how to get my chat command script to say something in-chat when you say (for example) /commands.
I’ve already tried some other topics on this, but they’re all overly complicated and arent clear on what they do.
Hey there!
This has pretty easy sloution, you can just call this script whenever you need to make that message (it will be only visible for client, from which it was executed).
game.StarterGui:SetCore("ChatMakeSystemMessage", {
Text = "Your text here :D, to make a new line, use \n";
Color = Color3.fromRGB(255,0,0); --Makes the message red, you can adjust this one
Font = Enum.Font.Cartoon; --Font that you like (to use arial do Enum.Font.Arial, etc...)
FontSize = Enum.FontSize.Size96; --I don't recommend changing this, but it's custom also :D
})
When I try it it doesn’t pop up in chat?
The whole code should look something like this, right?:
local prefix = "/"
game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
if msg:sub(1,#prefix) then
local command = msg:sub(#prefix + 1, #msg)
if command == "commands" then
--Make that message, I wrote before
end
end
end)
end)
Or something similar to this.
Or can you just send me the whole script, so I can analyze it?
local function onPlayerChatted(player, message)
–message = string.lower(message)
local command = string.match(message, "/kill ") --kill command
if(command == "/kill ") then
message = string.sub(message, 7)
if game.Players:FindFirstChild(message)~=nil then
local victim = game.Players:FindFirstChild(message)
if victim.Character and victim.Character:FindFirstChild(“Humanoid”) then
victim.Character.Humanoid.Health = 0
end
end
end
command = string.match(message, "/walkspeed ") --walkspeed command
if command == “/walkspeed " then
local split = string.split(message, " “)
local username
if split[2]~=nil then
username=split[2]
end
local speed
if split[3]~=nil then
speed = string.match(split[3],”%d+”)
end
if username~=nil and speed~=nil then
if game.Players:FindFirstChild(username) then
local victim = game.Players:FindFirstChild(username)
if victim.Character and victim.Character.Humanoid then
victim.Character.Humanoid.WalkSpeed = speed
end
end
end
end
command = string.match(message, "/jumppower ") --jumppower command
if command == "/jumppower " then
local split = string.split(message, " ")
local username
if split[2]~=nil then
username=split[2]
end
local power
if split[3]~=nil then
power = string.match(split[3],"%d+")
end
if username~=nil and power~=nil then
if game.Players:FindFirstChild(username) then
local victim = game.Players:FindFirstChild(username)
if victim.Character and victim.Character.Humanoid then
victim.Character.Humanoid.JumpPower = power
end
end
end
end
if command == "/commands " then
game.StarterGui:SetCore("ChatMakeSystemMessage", {
Text = "Use /commands to view commands";
Color = Color3.fromRGB(255,0,0); --Makes the message red, you can adjust this one
Font = Enum.Font.Cartoon; --Font that you like (to use arial do Enum.Font.Arial, etc...)
FontSize = Enum.FontSize.Size96; --I don't recommend changing this, but it's custom also :D
})
end
local function onPlayerAdded(player)
player.Chatted:Connect(function (message) onPlayerChatted(player, message) end)
end
game.Players.PlayerAdded:Connect(onPlayerAdded)
There you go, the full script.
Are other commands working properly?, is your game using custom chat?
There is another script in the game that uses chat dialogue that may be interfering.
and yes, every other command works properly.
print(“Loading”)
print(“Loading services…”)
local S_PS = game:GetService(“PhysicsService”)
local S_H = game:GetService(“HttpService”)
local S_ReS = game.ReplicatedStorage
print(“Loaded services”)
print(“Loading modules…”)
local M_Sounds = require(S_ReS:WaitForChild(“AssetsMod”):WaitForChild(“Sounds”))
local M_BI = require(S_ReS.AssetsMod:WaitForChild(“BlockInfo”))
local M_II = require(S_ReS.AssetsMod:WaitForChild(“ItemInfo”))
local M_IL = require(S_ReS.AssetsMod:WaitForChild(“ItemLevels”))
local M_R = require(S_ReS.AssetsMod:WaitForChild(“Recipes”))
print(“Loaded modules”)
print(“Creating physics groups”)
local P_Ch = S_PS:CreateCollisionGroup(“Character”)
local P_PN = S_PS:CreateCollisionGroup(“Particles”)
local P_W = S_PS:CreateCollisionGroup(“World”)
S_PS:CollisionGroupSetCollidable(“Particles”,“Default”,false)
S_PS:CollisionGroupSetCollidable(“Particles”,“Character”,false)
S_PS:CollisionGroupSetCollidable(“Particles”,“World”,true)
S_ReS.PhyGroups.Particles.Value = P_PN
S_ReS.PhyGroups.Character.Value = P_Ch
S_ReS.PhyGroups.World.Value = P_W
print(“Created physics groups”)
print(“Creating variables”)
local dmgmsgs = {
default = {“was slain”},
lava = {“tried to swim in lava”},
drown = {“drowned”},
fall = {“left a small crater”, “hit the ground too hard”},
void = {“fell out of the world”},
suffocation = {“suffocated in a wall”}
}
not the full script. But it also uses a chat script.
But the main chat frame still stays the same, right?
You mean like it doesn’t say anything?
If so, the Death messages do show.
Wait a second, that script with commands, you sent me- is it actually notmal Script or a LocalScript?
Normal Script I’m pretty sure.
Alright, you’ll have to make a remote event, that will fire the client, who did /commands
On server:
local event = game.ReplicatedStorage.SystemMessageEvent --Or whatever your event will be
event:FireClient(player, "YOUR TEXT HERE")
On client (most likely in StarterPlayer):
local event = game.ReplicatedStorage.SystemMessageEvent --Or whatever your event will be
event.OnClientEvent:Connect(function(text)
game.StarterGui:SetCore("ChatMakeSystemMessage", {
Text = text;
Color = Color3.fromRGB(255,0,0); --Makes the message red, you can adjust this one
Font = Enum.Font.Cartoon; --Font that you like (to use arial do Enum.Font.Arial, etc...)
FontSize = Enum.FontSize.Size96; --I don't recommend changing this, but it's custom also :D
})
end)
To be clear,
local event = game.ReplicatedStorage.SystemMessageEvent --Or whatever your event will be
event:FireClient(player, “YOUR TEXT HERE”)
Goes in the command chat script, and the
local event = game.ReplicatedStorage.SystemMessageEvent --Or whatever your event will be
event.OnClientEvent:Connect(function(text)
game.StarterGui:SetCore(“ChatMakeSystemMessage”, {
Text = text;
Color = Color3.fromRGB(255,0,0); --Makes the message red, you can adjust this one
Font = Enum.Font.Cartoon; --Font that you like (to use arial do Enum.Font.Arial, etc…)
FontSize = Enum.FontSize.Size96; --I don’t recommend changing this, but it’s custom also
})
end)
goes in StarterPlayerScripts?
Hey, just making sure you got it?
Sorry for the late answer, but
The part I marked with On server: goes into that script with all of your admin comamnds and the part I marked with On client: goes into local script, which I preffer to store in StarterPlayer.
Alright, thanks. I’ll try that.
Also, don’t forget to create the remote event inside of ReplicatedStorage