Introduction
Hello, I’m @BazirGames. I wanted to share this module I made for client, server, script communication. This module will create RemoteFunction, RemoteEvent, BindableEvent, and BindableFunction so you don’t have to.
sources:
BazirRemote
Why use BazirRemote?
- Easy to use
- Improves your workflow
- Spend less time creating RemoteFunction, RemoteEvent, BindableEvent, and BindableFunction
Setup
API
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local BazirRemote = require(ReplicatedStorage.BazirRemote)
local Remote = BazirRemote.new("Stats.Coins") --or BazirRemote.new({"Stats", "Coins"})
Remote:Fire(...)
Remote:Invoke(...)
Remote.Event:Connect(function(player)
end)
Remote.OnInvoke = function(...)
end
--client
Remote:FireServer(...)
Remote:InvokeServer(...)
Remote.OnClientEvent:Connect(function(...)
end)
Remote.OnClientInvoke = function(...)
end
--server
Remote:FireClient(player, ...)
Remote:InvokeClient(player, ...)
Remote:FireAllClients(...)
Remote.OnServerEvent:Connect(function(player, ...)
end)
Remote.OnServerInvoke = function(player, ...)
end
Examples
1
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local BazirRemote = require(ReplicatedStorage.BazirRemote) -- require the module
--client
local Remote = BazirRemote.new("player.respawn")
Remote:FireServer()
--server
local Remote = BazirRemote.new("player.respawn")
Remote.OnServerEvent:Connect(function(player)
player:LoadCharacter()
end)
2
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local BazirRemote = require(ReplicatedStorage.BazirRemote) -- require the module
--client
local Remote = BazirRemote.new("data")
delay(5, function()
local ReturnData = Remote:InvokeServer()
if ReturnData then
print("Coins: " .. ReturnData.Coins)
print("Gems: " .. ReturnData.Gems)
else
warn("InvokeServer data failed")
end
end)
--server
local Remote = BazirRemote.new("data")
Remote.OnServerInvoke = function(player, ...)
return {
Coins = 30,
Gems = 15
}
end
3
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local BazirRemote = require(ReplicatedStorage.BazirRemote) -- require the module
--client or server
--script 1:
local Remote = BazirRemote.new("client.print")
Remote.OnEvent:Connect(function(...)
print(...)
end)
--script 2:
local Remote = BazirRemote.new("client.print")
delay(15, function()
Remote:Fire("This is printed on script 1 :)")
end)