How would I make a message show on screen similar to the ones that appear when you get badges?

I want to make custom messages similar to the ones that show up on the bottom right of the screen when you get badges

local TweenService = game:GetService("TweenService")
local moveFrame = TweenInfo.new(
    1, --Time in seconds the tween will last
    Enum.EasingStyle.Sine, --What easing style you want to use
    Enum.EasingDirection.InOut --What easing direction you want to use
    0, --How many times this tween should loop, -1 means indefinite
    false, --whether or not the tween should move in reverse
    0 --time in seconds the tween will wait before starting (delay time)
)

local Frame = --your frame location
local Message = Frame:WaitForChild("Message") --replace with your TextLabel destination and name

--Anchor point allows us to easily position them from different edges of your viewport
local finalAnchorPoint = Vector2.new(1, 1) --final anchorpoint our frame will take
local startAnchorPoint = Vector2.new(0, 1) --starting anchor point

Frame.AnchorPoint = startAnchorPoint
 --adds a 100 pixel marge on the Y axis
Frame.Position = UDim2.new(1, 0, 1, -100) --Will be off screen if AnchorPoint is set to startAnchorPoint

local function showBadgeMessage(message :string)
    Message.Text = message

    local showMessage = TweenService:Create(
        Frame, --The gui element you want to move
        moveFrame , --the TweenInfo you want to use
        { --table of multiple properties you want to change
            AnchorPoint = finalAnchorPoint
        }
    )

    showMessage:Play() --Plays the tween
    showMessage.Completed:Wait() --Waits for the tween to finish. Keep in mind this will force the function to yield

    task.wait(5) --Time in seconds you want this message to appear for
    
    --We don't need to define a tween if we don't need to wait for it to complete, we can also play it right away
    TweenService:Create(Frame, MoveFrame, {  AnchorPoint = startAnchorPoint }):Play()
end

showBadgeMessage("You received a new badge: You made it!") --Call the function whenever you need to show the message.

Let me know if you have any questions!

You can create an identical prompt similar to badges in a localscript using StarterGui:SetCore. Specifically the SendNotification method.

As an example:

game.StarterGui:SetCore("SendNotification", {
    Title = "Wild woods",
    Text = "You have discovered a new area!"
})

Hope this helps :smiley:

1 Like

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