Start your scripting journey: create notifications

Welcome to my first ever tutorial/guide here on the developer forum.

This post was inspired by the huge amount of times I’ve been asked on how to script and how I learnt it.
As well as the lack of youtube videos (in my opinion) which give explanation to specific points which are definitely a must do!

In this post, I will overall be explaning how to start your journey as a Roblox scripter by letting you come alongside as we create a notifications system

:warning: This tutorial is designed to be very slow-paced and hopefully give a lot of insight on what we are doing

Before we start anything, let’s get into…

The difference between server and client are stuff you must learn!
To cut it simple, the client is a way for developers to detect player input and display information whilst the server is responsible for game logic. This could be saving user data or adjusting.

One major thing is that, when you run a code on a client, then it is only available to be seen by the client. If you move an object on the client, then only the client can see it, whilst if you did it with the server then everyone could see it in the game. Viable code should not be put in the client, as exploiters can access local scripts and modules!: Learn more about the client-server behaviour here;

I will not be explaning everything to do with basics, so therefore I suggest you go ahead and do the introduction to coding( Getting Started ) by Roblox

One of the most useful features in a roblox script are variables
Variables are a way to quickly define an object, vectors, positions, players and onwards. It is up to you what you wish to save. Variables can also be used for aesthetic or script organization reasons.

Let’s start off our notifcations system by creating a script and placing it in the ServerScriptService
image

Name this script whatever you want, but in this case I’ll just leave it empty.

When creating a script, it is important that you know the purpose and what services you will be using.
In this script, we will be using the ReplicatedStorage for quick access to events and Players to quickly accessing the players in-game (more about that later)

Notifications show up on the players screen, so therefore we know that the server will be responsible for delivering the notifcations.

Define ReplicatedStorage and Players in the script as such:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

This variable will make it easy to call the ReplicatedStorage!

For this part, please open up the following website as it will be used a lot.
RemoteEvent API ref: RemoteEvent

As stated before, there is a huge difference between the client and the server. Therefore, we of course need make connections between the couple. We can use RemoteEvents or RemoteFunctions for this. For this tutorial, we will be using remote events as they are more for delivering, whilst remotefunctions are more for requesting information from the server.

Let’s create a remote event:
Go into ReplicatedStorage and create a new RemoteEvent.
image

Name the RemoteEvent anything!
In my instance, I’m going to name the RemoteEvent for NotifcationHandler

We can now define our remote event in our variables.

(The spaces are my own personal aesthetic, they are not required.)

I’ve used a function which I have not explained before. This is :WaitForChild()
If you want to know more about WaitForChild, please head into the page linked.

Going into the Roblox API ref, we can see all of the different functions and properties that a remote event has. We do not need to adjust any properties on the remote event, rather we need to use functions.

Scroll down to the functions part on the page

On the API page, we can see what the different kinds of functions do and what data they can give us.

In this instance, we are going to be making the notification system send out a notification once a player joins.

To indicate that a player has joined the game, we must use the PlayerAdded event!

The PlayerAdded event will run whenever a player joins the game. Scrolling down on the PlayerAdded page, we can see the parameters which are included when this event is run.

We can deem this event as a fit for us, as it does what we want it to.

We have now collected everything we need for the server!
We can now create our function:

The server now knows that it has to react when a player joins.
Now, let’s give the player a welcoming when they join.

Using FireClient on our RemoteEvent (look back into the tutorial) we will be giving the player a welcoming.
When using FireClient, we need to define the player first. Inside of the function, type the following:

RemoteEvent:FireClient(player)

Since we also want the player to get a specific message once they join, let’s put it into the remote event as well.

RemoteEvent:FireClient(player, "Welcome to the server!")

Your code should now look alike this:

We have now officially set up the server!

:warning: This tutorial is NOT a guide on how to create GUI as well, therefore I will be linking my own place here with the complete guide and will be using this in the tutorial. If you wish to create your own GUI, search for another guide on the devforum or roblox api!

It is important that you GUI has:

  • A frame where the message will appear
  • The textlabel, configured to have your message on it

image

Create a localscript, and put the textlabel in the local script. We will be using this as storage for now.

Let’s start scripting.
First, use what you’ve already learnt to define the frame and the textlabel
image

Another function of the remotevent is OnClientFunction!
Looking into the API page, we can see that it gives us the arguments which were stated in the firing. In this instance, we gave the client a welcome message as our argument.

Connect the event in the local script as shown:

Argument1 in this case, is our welcome message which we defined when we fired the remote!
Let’s make it so that the textlabel clones itself, and is there for a bit. To do this, we need to look at what a TextLabel can do.

Looking into the API page, we can see the clone function.
Let’s use it.

In the function, do the following line:

	local Clone = TextLabel:Clone()

This will differenciate the clone and the original textlabel.
Now, you can change up the properties. But it is important that we first of all define the text.
Use the following:

local Clone = TextLabel:Clone()
Clone.Text = argument1

Now that we’ve defined everything required, you can go ahead and look at more properties and change based on your preferences. When done, come back.

Now that we are done setting preferences, we need to make it appear on the players screen!
Add the following under:

Clone.Parent = Frame

Your script should look something like this now:

If we ran this now, it would simply just stay there forever. Therefore we need to make a wait function!
The Wait() function will cause the script to pause for that amount of time inputted.

For this instance, I want the message to appear for 5 seconds!
After it has been 5 minutes, we need to get rid of it as well. Since it is a clone, we can simply :Destroy it!

Your script should now look like this:

The script should now work, go ahead. Playtest it!

THANK YOU
I appreciate you taking the time to join along and start learning scripting.
Remember that errors and troubles will come along the way.

As mentioned before, this is my first guide and I hope you enjoyed it. I do hope you learnt something from this.!

TROUBLE SHOOTING
This did not make an official point in the tutorial, but when experiencing errors or troubles with your scripts then go and seek help from either the API reference page or search around on DevForum for people with similar issues.

MY FILE:
Notifications.rbxl (39.3 KB)

  • You can use this file to assist you with learning or grabbing the gui. Everything shown in the guide is included here. Make sure to stay original though!

:wave:

8 Likes

You should use task.wait() instead of wait() as it will be deprecated soon.
Also looks a bit similar to my resource. Is there a difference? (not trying to accuse you of anything.)

The notifications system I was using in this guide was not plagarized or stolen in any way.
This is how I usually do notifcations in my own games, just with less detail since it is a beginners guide.

1 Like

I haven’t used your HintService, but this tutorial is very basic and aimed towards beginners. If your code is so basic that you accuse someone of plagiarising because they made something simple, I think you shouldn’t be worrying about their code, but be questioning whether your code is complex enough to even be on Resources page:

  • Significant overall ; your contributions must be more substantial than small scripts or a few individual assets. Resources that are not significant enough, too specific / not useful to many people, or too low quality should be posted in a different forum category.

^Community rules for Resources

2 Likes

That sounds pretty real I gotta say