Server message command

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve?
    I want to make a server message script and I don’t get familiar w chat server message.I want it when you chat “!ServerMessage [text]” It will show text for all player’s gui.

  2. What is the issue? The script doesn’t work.I tried to chat the command with a text after the command but it doesn’t show up gui or anything

  3. What solutions have you tried so far? Yes I did but it just show server message in chat only.Not gui.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
SERVER SIDED:

game.Players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(message)
		if message:sub(1, 14) == "!ServerMessage" then
			local text = message:sub(16)
			game.ReplicatedStorage.ServerMessage:FireAllClients(text)
		end
	end)
end)

GUI CILENT SIDED

game.ReplicatedStorage.ServerMessage.OnClientEvent:Connect(function(text)
	script.Parent.TextLabel.Text=text
	
	game:GetService("TweenService"):Create(script.Parent.ServerMessagePlace,TweenInfo.new(1,Enum.EasingStyle.Sine),{TextTransparency=0}):Play()
	game:GetService("TweenService"):Create(script.Parent.TextLabel,TweenInfo.new(1,Enum.EasingStyle.Sine),{TextTransparency=0}):Play()
		game:GetService("TweenService"):Create(script.Parent,TweenInfo.new(1.8,Enum.EasingStyle.Sine),{Transparency=0.8}):Play()
	task.wait(6.5)
	game:GetService("TweenService"):Create(script.Parent.ServerMessagePlace,TweenInfo.new(1,Enum.EasingStyle.Sine),{TextTransparency=1}):Play()
	game:GetService("TweenService"):Create(script.Parent.TextLabel,TweenInfo.new(1,Enum.EasingStyle.Sine),{TextTransparency=1}):Play()
	game:GetService("TweenService"):Create(script.Parent,TweenInfo.new(1.8,Enum.EasingStyle.Sine),{Transparency=1}):Play()
end)
2 Likes

try to use this in ur server script:

game.Players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(message)
		if message:sub(1, 14) == "!ServerMessage" and message:len() >= 16 then
			local text = message:sub(16,message:len())
			game.ReplicatedStorage.ServerMessage:FireAllClients(text)
		end
	end)
end)
2 Likes

use this:

local canSendNewMessage = true
local messageQueue = {}

game.Players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(message)
        local split = message:split(" ")
        if split[1]:lower() == "!servermessage" then
           if canSendNewMessage then
              task.spawn(function()
                  canSendNewMessage = false
		          game.ReplicatedStorage.ServerMessage:FireAllClients(table.concat(split, " ", 2))
                  task.wait(6.5)
                  canSendNewMessage = true
              end)
           else
              table.insert(messageQueue, table.concat(split, " ", 2))
           end
        end
	end)
end)

task.spawn(function()
   while task.wait(6.5) do
      if #messageQueue ~= 0 then
         game.ReplicatedStorage.ServerMessage:FireAllClients(messageQueue[1])
         table.remove(messageQueue, 1)
      end
   end
end)

the messageQueue was designed so that you cannot spam messages and interfere with the gui

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.