How can i make a global event

Ok so i am trying to make a nuke gamepass that nukes all servers does anybody know a script that can do this

18 Likes

you can use MessagingService to communicate this should happen to all servers

12 Likes

You can use MessagingService and its :PublishAsync() and :SubscribeAsnyc() (from what I remember) methods to accomplish this

7 Likes

Because I am a very new scripter I can’t write you a code but you can use MessagingService

8 Likes

ok thanks i love char limitttttttttttttt

6 Likes

wait well what i mean by that is i have a nuke and when somebody buys it i want it to activate in all server

6 Likes

Yes you can use the messagingService to do that.

6 Likes

i want the nuke too oof everybody in every server

8 Likes

First publish the nuke activation. When someone buys the nuke gamepass, you can use MessagingService:PublishAsync() then Subscribing to the Nuke Activation: In each server, you would use MessagingService:SubscribeAsync() to listen for the activation message. When the message is received, the server would then trigger the nuke effect to occur.

here’s a basic example:

local MessagingService = game:GetService("MessagingService")

local NukeActivationChannel = "NukeActivationChannel"

-- Function to activate the nuke effect
local function ActivateNuke(data)
    -- Implement the nuke effect here
    print("Nuke activated!")
end

-- Subscribe to the nuke activation channel
local function SubscribeToNukeActivation()
    MessagingService:SubscribeAsync(NukeActivationChannel, function(message)
        ActivateNuke(message.Data) -- Call the function to activate nuke
    end)
end

-- Initialize
SubscribeToNukeActivation()

-- When the nuke gamepass is bought
local function OnGamepassBought(player, gamepassId)
    -- Check if the bought gamepass is the nuke gamepass
    if gamepassId == YOUR_NUKE_GAMEPASS_ID then
        -- Publish message to activate nuke
        local message = {
            Data = {
                Buyer = player.Name,
                GamepassId = gamepassId
            }
        }
        MessagingService:PublishAsync(NukeActivationChannel, message)
    end
end

game.Players.PlayerAdded:Connect(function(player)
    player.GamePassPurchased:Connect(function(gamepassId)
        OnGamepassBought(player, gamepassId)
    end)
end)
7 Likes

how could i link the nuke to the gampass tho

5 Likes
local MessagingService = game:GetService("MessagingService")

local NukeActivationChannel = "NukeActivationChannel"
local YOUR_NUKE_GAMEPASS_ID = 123456789 -- Replace with your actual gamepass ID

-- Function to activate the nuke effect
local function ActivateNuke(data)
    -- Implement the nuke effect here
    print("Nuke activated!")
end

-- Subscribe to the nuke activation channel
local function SubscribeToNukeActivation()
    MessagingService:SubscribeAsync(NukeActivationChannel, function(message)
        ActivateNuke(message.Data) -- Call the function to activate nuke
    end)
end

-- Initialize
SubscribeToNukeActivation()

-- When the nuke gamepass is bought
local function OnGamepassBought(player, gamepassId)
    -- Check if the bought gamepass is the nuke gamepass
    if gamepassId == YOUR_NUKE_GAMEPASS_ID then
        -- Publish message to activate nuke
        local message = {
            Data = {
                Buyer = player.Name,
                GamepassId = gamepassId
            }
        }
        MessagingService:PublishAsync(NukeActivationChannel, message)
    end
end

game.Players.PlayerAdded:Connect(function(player)
    player.GamePassPurchased:Connect(function(gamepassId)
        OnGamepassBought(player, gamepassId)
    end)
end)

Just update YOUR_NUKE_GAMEPASS_ID with the actual ID of your nuke gamepass.

5 Likes
MessagingService:PublishAsync("THE WORLD IS ENDING!", plr.Name) 

The first string “THE WORLD IS ENDING!” is the event that gets activated in every server, and the second string can be a message that also gets sent with that.

MessagingService:SubscribeAsnyc("THE WORLD IS ENDING! ", function(name)
	print(name.. "wants kaboom!") 
end) 

In this example, every server prints the name of the player followed by “wants kaboom!”. You may change the event name from “THE WORLD IS ENDING!” to something else, but make sure that both the publish- and subscribeAsync methods have the same event name.

Edit: I just noticed that the part with the message that I sent between the servers could be wrong so take this code example very lightly. Make sure to read the developer documentation about messagingService to get a firm grip on the basics of this service

6 Likes

so that script you wrote has the part that kills players?

5 Likes

No, that’s why they wrote “implement the nuke effect here”

4 Likes

i think i have everything right why wont txt apear?

4 Likes

local MessagingService = game:GetService(“MessagingService”)

local NukeActivationChannel = “NukeActivationChannel”
local YOUR_NUKE_GAMEPASS_ID = 1613997626 – Replace with your actual gamepass ID

– Function to activate the nuke effect
local function ActivateNuke(data)
– Implement the nuke effect here
print(“Nuke activated!”)
end

– Subscribe to the nuke activation channel
local function SubscribeToNukeActivation()
MessagingService:SubscribeAsync(NukeActivationChannel, function(message)
ActivateNuke(message.Data) – Call the function to activate nuke
end)
end

– Initialize
SubscribeToNukeActivation()

– When the nuke gamepass is bought
local function OnGamepassBought(player, gamepassId)
– Check if the bought gamepass is the nuke gamepass
if gamepassId == 1613997626 then
– Publish message to activate nuke
local message = {
Data = {
Buyer = player.Name,
GamepassId = gamepassId
}
}
MessagingService:PublishAsync(NukeActivationChannel, message)
end
end

game.Players.PlayerAdded:Connect(function(player)
player.GamePassPurchased:Connect(function(gamepassId)
OnGamepassBought(player, gamepassId)
end)
end)

4 Likes

how can i make an effect???

2 Likes

Well, I thought you originally wanted to kill all players in the server? It’s up to you.

2 Likes

i want all players in every server killed

1 Like

bu ti waant effect for when nuke goes off

1 Like