SetMessage (Function): Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>Camoy
corrected
>ArceusInator
Added a script that allows users to create doppelgangers of this function and its sibling, ClearMessage().
Line 12: Line 12:
</onlyinclude>
</onlyinclude>
|}
|}
{{Example|
<pre>
game:SetMessage( "Hello World" )
-- Will result in the image below
</pre>}}


[[Image:setmessage.jpg]]
[[Image:setmessage.jpg]]
{{Example|
It is actually possible to create a sort of doppelganger of this function and its sibling, ClearMessage, by running this code:
<pre>
local message = false
function _G.SetMessage( msg )
  if not msg then return ( error( "String expected", 1 ) ) end
  if type( msg ) ~= "string" then return ( error( "String expected", 1 ) ) end
  if message then
      game:ClearMessage()
  end
  local p = game.Players:GetPlayers()
  if not p then return end
  for i = 1, #p do
      if p[i]:FindFirstChild( "PlayerGui" ) then
        local s = Instance.new( "ScreenGui", p[i].PlayerGui )
        local t = Instance.new( "TextLabel", s )
        t.Position = UDim2.new( 0.2, 0, 0.354, 0 )
        t.BorderColor3 = Color3.new( 192/255, 192/255, 192/255 )
        t.BackgroundColor3 = Color3.new( 163/255, 162/255, 165/255 )
        t.Size = UDim2.new( 0.6, 0, 0.29, 0 )
        t.FontSize = Enum.FontSize.Size24
        t.Text = ( tostring( msg ) )
        t.TextColor3 = Color3.new( 1, 1, 1 )
        t.BackgroundTransparency = 0.4
        s.Name = "gameMessage"
      end
  end
  message = true
end
function _G.ClearMessage()
  if not message then return end
  local p = game.Players:GetPlayers()
  if not p then return end
  for i = 1, #p do
      if p[i]:FindFirstChild( "PlayerGui" ) then
        local g = p[i].PlayerGui:GetChildren()
        for x = 1, #g do
            if g[x].Name == "gameMessage" then
              g[x]:remove()
            end
        end
      end
  end
  message = false
end
</pre>}}

Revision as of 19:42, 27 December 2010

This function is locked. Using it will cause an error.
SetMessage( String message text )
Returns n/a
Description: Creates a GUI message similar to ones seen when loading a game.
Example
game:SetMessage( "Hello World" )

-- Will result in the image below



Example

It is actually possible to create a sort of doppelganger of this function and its sibling, ClearMessage, by running this code:


local message = false

function _G.SetMessage( msg )
   if not msg then return ( error( "String expected", 1 ) ) end
   if type( msg ) ~= "string" then return ( error( "String expected", 1 ) ) end
   if message then
      game:ClearMessage()
   end
   local p = game.Players:GetPlayers()
   if not p then return end
   for i = 1, #p do
      if p[i]:FindFirstChild( "PlayerGui" ) then
         local s = Instance.new( "ScreenGui", p[i].PlayerGui )
         local t = Instance.new( "TextLabel", s )
         t.Position = UDim2.new( 0.2, 0, 0.354, 0 )
         t.BorderColor3 = Color3.new( 192/255, 192/255, 192/255 )
         t.BackgroundColor3 = Color3.new( 163/255, 162/255, 165/255 )
         t.Size = UDim2.new( 0.6, 0, 0.29, 0 )
         t.FontSize = Enum.FontSize.Size24
         t.Text = ( tostring( msg ) )
         t.TextColor3 = Color3.new( 1, 1, 1 )
         t.BackgroundTransparency = 0.4
         s.Name = "gameMessage"
      end
   end
   message = true
end

function _G.ClearMessage()
   if not message then return end
   local p = game.Players:GetPlayers()
   if not p then return end
   for i = 1, #p do
      if p[i]:FindFirstChild( "PlayerGui" ) then
         local g = p[i].PlayerGui:GetChildren()
         for x = 1, #g do
            if g[x].Name == "gameMessage" then
               g[x]:remove()
            end
         end
      end
   end
   message = false
end