Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

how can i send a system message back like "not found" on the chat when i enter a command?

Asked by 5 years ago
Edited 5 years ago

i tryed this but get back the channel is nil and the warn is only for server message for output

local AdminCommands = require(1163352238)
local Utilities = AdminCommands.Utilities

local ZombyGame = "/zombie "

local function onOwnerChatted(player, message, channel)

    if message:sub(1, ZombyGame:len()):lower() == ZombyGame:lower() then

        local aMessage = message:sub(ZombyGame:len() + 1)

        if aMessage == "on" then

            local zombiegame = game.ReplicatedStorage.MiniGames:FindFirstChild("ZombieGame")

            if zombiegame then

                zombiegame.Parent = workspace

            else

                warn "Not Found"
                channel:SendSystemMessage ( "Not Found" )

            end

        end

        if aMessage == "off"then

            local zombiegame = workspace:FindFirstChild("ZombieGame")

            if zombiegame then

                zombiegame.Parent = game.ReplicatedStorage.MiniGames

            else

                warn "Not Found"
                channel:SendSystemMessage ( "Not Found" )

            end

        end

    end
end

local function onPlayerAdded(player)
-- Restrict this command to only the creator/owner
    local Name = lol --my name
    local Id = 123456789 --my id change this both

    if player.UserId == game.CreatorId and game.CreatorType == Enum.CreatorType.User or player.Name == Name and player.UserId == Id then
        player.Chatted:Connect(function (...)
            onOwnerChatted(player, ...)
        end)
    end

end

-- Listen for players being added
for _, player in pairs(Players:GetPlayers()) do
    onPlayerAdded(player)
end
Players.PlayerAdded:Connect(onPlayerAdded)

i did have made my own channel and this script is a normale script in ServerScriptService

1 answer

Log in to vote
1
Answered by 5 years ago

Unfortunately you can not send a system message from a regular script. It must be called from a localscript. What you can do is have a localscript inside starter player scripts (or StarterGui) that listens for a remote event. Here's how I'd approach it (Untested):

 -- Local Script (game.StarterPlayer)
local event = game:GetService("ReplicatedStorage"):FindFirstChild("ServerMessage")
if nil == event then
    repeat
        event = game:GetService("ReplicatedStorage"):WaitForChild("ServerMessage", 10)
        wait(0.1)
    until nil ~= event
end
event.OnClientEvent:Connect(function(message, font, font_size, brick_color)
    brick_color, font, font_size = brick_color or BrickColor.new("Dark stone grey"), font or Enum.Font.Cartoon, font_size or  Enum.FontSize.Size96
    game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage", {
        Text = tostring(message or "Hello World"),
        Font = font,
        Color = brick_color.Color,
        FontSize = font_size
    })
end)
-- Script in ServerScriptService
function SystemMessage(...)
    spawn(function()
        local event = game:GetService("ReplicatedStorage"):FindFirstChild("ServerMessage")
        if nil == event then
            event = Instance.new("RemoteEvent", game:GetService("ReplicatedStorage"))
            event.Name = "ServerMessage"
            wait(1.25)
        end
        if nil ~= event then
            event:FireAllClients(...)
        end
    end)
end

SystemMessage("Lz was here")
0
ok so i have to make an event for that so when in my script its not found i have to fire that event User#27824 0 — 5y
0
There are countless variations but basically, yes. LucarioZombie 291 — 5y
Ad

Answer this question