MultitaskAlert - A Simple System for Mulitaskers

MultitaskAlert

Introduction

Hello everyone! :wave: I’m @FxllenCode, and today I am releasing my first little system, MultitaskAlert. I’m going to start with a simple poll:

How important is multitasking in the development process?

  • Multitasking is an important part of the development process.
  • Multitasking is not an important part of the development process.

0 voters

Likely, most people believe it is important. This is what had lead me to create this system.


If you have a small game, you likely want to greet people who join. This has been proven to make them stay in the game longer, thus potentially moving them from a player to a paying player. As a developer, I often do not have the time to sit around in the game and wait for people to join. I usually will open up studio, and start working. Even with 2 monitors, I usually have studio open on one, and documentaion or other sites open on the other. I forget that people join, and they end up leaving as I am AFK.

Introducing MultitaskAlert! :tada:

MultitaskAlert is a simple system consisting of three things: A Script, a LocalScript, and a RemoteEvent. Don’t fret, I’ll get into setup later! :partying_face: MultitaskAlert is a system that will alert you when a player enters your game. How, you may ask? The system will play an alert noise in game when someone joins. This noise is Client-Sided, and only the whitelisted user will hear it (I’ll get into that later). On top of that, you must say a command in the chat to turn on the system, that way you aren’t bombarded by noise when you aren’t AFK. Currently, only 1 user can be whitelisted, however I am working on V2, which will be much simpler, and have more functionality.

How does it work?

As stated above, it consists of a Script, a LocalScript, and a RemoteEvent. The script checks to make sure the user is whitelisted, and it also checks that the user has said the command. Once it confirms both of these, it waits until someone joins. When they join, it fires the remote event, which plays the sound on the whitelisted users’ game. As of now, the script isn’t as clean or as efficient as it could be, V1 has mainly been for functionality, now that it’s functional, I’ll be starting a complete rewrite of this.

Where can I get it?

Grab the model here:

How to set it up?

Grab the model and put it into your roblox game. Then, open up the README, and read it! It will give you in depth instructions. It’s quite simple.

FAQ

Q: Why should I use this?

A: It’s good to use if you want to greet new players who join your game, but don’t have the time to sit around and do nothing.

Q: Can I change the commands?

A: Yes! The command can be changed. Make sure to read the README.

Q: I have a bug, how can I report it?

A: Let me know in the comments below.

More information

Update Log

V1.01

Updated:
2020-10-11T22:18:00Z

Topic Edit Log

Last edit: 2020-10-11T22:19:00Z

Support the developer

Thank you for your interest in supporting me! Here is a game, new one coming soon:

Frozen Mountain - Showcase - Roblox

Code

Before I show the code, yes, I know it could be better. Like I said, v1 is going for functionality. I know there are much better methods. I am interested to hear your thoughts however, I will keep these in mind during v2.

MultiServer
-- Editable Features: 

local username = "FxllenCode" -- Username of whitelisted user goes here, used for remote event.

local allowed = 82738847 -- UserID of whitelisted user goes here.

local commandStart = "!startAlerts" -- You can change this to whatever you want.

local commandEnd = "!endAlerts" -- This one too.

local sound = "1403257129" -- Set this to any audio ID you would like.



-- Do not touch the lines below unless you know what your are doing.

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local Players = game:GetService("Players")

local remoteEvent = ReplicatedStorage:WaitForChild("PlaySound")

local check = false

local enabled = false

local confirm = false



local cache = {}
function getUserIdFromUsername(name)
	-- First, check if the cache contains the name
	if cache[name] then return cache[name] end
	-- Second, check if the user is already connected to the server
	local player = Players:FindFirstChild(name)
	if player then
		cache[name] = player.UserId
		return player.UserId
	end 
	-- If all else fails, send a request
	local id
	pcall(function ()
		id = Players:GetUserIdFromNameAsync(name)
	end)
	cache[name] = id
	
	return id
	
	
end



	
function checkForPerms(name)
	
	local id = getUserIdFromUsername(name)
	
	if id == allowed then 
		
		check = true
		print("Sound Perms")
		print(id)
		
	else
		
		check = false
		print("No perms")
		print(id)
		
	end
	end	



function pausePerms(player)
	
	if enabled == true then
		
		
		confirm = false
		enabled = false
		
	end
	
	
end




function confirmPerms(player)
	
	if check == true then
		
		confirm = true
		
		while confirm == true do 
			
			enabled = true
		
			wait(5)
			
		end
	
		
	end
	
end


Players.PlayerAdded:Connect(function(player)
	checkForPerms(player.Name)
end)

game.Players.PlayerAdded:Connect(function(player) -- call the yes
	player.Chatted:Connect(function(message)
		if message == commandStart then
			
			confirmPerms(player)
			
			
		end
	end)
end)

game.Players.PlayerAdded:Connect(function(player) -- stop calling the yes
	player.Chatted:Connect(function(message)
		if message == commandEnd then
			
			pausePerms(player)
			
		
		end
	end)
end)


game.Players.PlayerAdded:Connect(function()
	if enabled then
		print("e")
		
		remoteEvent:FireClient(game:GetService("Players"):FindFirstChild(username), sound)		
		
	end
end)
	

print(check)
print(allowed)
print()
MultiClient
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local remoteEvent = ReplicatedStorage:WaitForChild("PlaySound")

local alert = Instance.new("Sound", game.Workspace)

local function playAlertSound(sound)
	
	alert.SoundId = "rbxassetid://" .. sound
	alert:Play()

	
end
	
	
	
	
	remoteEvent.OnClientEvent:Connect(playAlertSound)

Conclusion

If you have any questions or concerns, feel free to let me know below! If you use it, I would be honored to see which game it is in! I always like to see the place my product is being used. Finally, thank you for the support. I know usually I’m the guy who makes giant terrain showcases, but today, I’m playing scripter! :sunglasses:

Thank you so much! :grinning:

4 Likes

Developers of good games aren’t always in game, so why would we need this? It seems kinda pointless honestly. Why would devs need a noise when someone joins a game?

2 Likes

Hey, thanks for your concern. This is more for smaller developers, who might not get a ton of players, but wants to greet them. I thought I wrote that in the topic. Thank you for pointing that out, I will edit the topic if necessary.

1 Like

Lol, wasted a name on this. Could’ve named it PlayerSignal, JoinAlert or something short and actually descriptive and fitting.

It is time for :clap: code review :clap:

Firstly, put everything on the client, there’s absolutely NO reason for it to be on the server. Why? Because let’s say an exploiter does access this… what do they get out of it? A pling noise from players joining? Not very destructive is it

The getIdFromPlayer function is completely redundant and useless. Players.PlayerAdded triggers an event when a player has joined, there’s no real reason to validate whether they’re a person that joined before if you ABSOLUTELY don’t want that which sounds to be quite stupid. It is much more likely for a new user to join than a person to rejoin. Don’t over-engineer something so simple which could be completely replaced in one line of code.

The check for perms is fundamentally just overlooking the obvious, instead of passing a string of which you have to get an object with later on, AND THEN get the userId, just pass the argument directly. from the beginning.

And instead of looping over and over and over… again, use signal based coding which is instant :slight_smile:

Here’s my iteration of the code, feel free to fork it.

5 Likes

Hey, awesome, thank you so much! I will keep everything in mind, and change the name. Code wise, I will fork your code and use it for v2. The current code was mainly getting the idea on the plate and making it functional, now I’ll be making it cleaner! Thank you!

1 Like