For some reason whenever I use messaging service, the first time I call it, it runs the code once but when i call it for the second time it runs the code 2 times instead of running it once and it keeps on going in that pattern. Does anyone know how to stop this? Here’s my script:
game.ReplicatedStorage.SendMsg.OnServerEvent:Connect(function(player, Server)
local messagingService = game:GetService("MessagingService")
local number = 0
messagingService:SubscribeAsync("Plane", function()
print("test")
number += 1
if number == 1 then return end
end)
messagingService:PublishAsync("Plane")
end)