I am making a global announcement system and for some reason the RemoteEvent: GlobalSender is thinking that the msg
argument is my playername.
– SERVERSCRIPT: NotificationHandler –
local replicatedStorage = game.ReplicatedStorage
local rebirth = replicatedStorage.Rebirth
local messagingService = game:GetService("MessagingService")
function rebirth.OnServerInvoke(plr)
if plr.leaderstats.Cash.Value >= 5000 then
plr.leaderstats.Cash.Value = 0
plr.leaderstats.Rebirths.Value = plr.leaderstats.Rebirths.Value + 1
game.ReplicatedStorage.RebirthMessage:FireAllClients(plr.Name)
return "Rebirthed"
else
return "NotEnough"
end
end
messagingService:SubscribeAsync("GlobalMsg",function(globalMessage)
print(globalMessage.Data)
replicatedStorage.GlobalReceiver:FireAllClients(globalMessage.Data)
end)
function serverEventGlobalSend(msg)
messagingService:PublishAsync("GlobalMsg",tostring(msg))
end
replicatedStorage.GlobalSender.OnServerEvent:Connect(serverEventGlobalSend)
– LOCALSCRIPT: ClientEventReceiver –
local ReplicatedStorage = game.ReplicatedStorage
local Players = game.Players
ReplicatedStorage.RebirthMessage.OnClientEvent:Connect(function(Playername)
local ThumbnailId = Players:FindFirstChild(Playername).UserId
local ThumbType = Enum.ThumbnailType.HeadShot
local ThumbSize = Enum.ThumbnailSize.Size420x420
local Content, IsReady = Players:GetUserThumbnailAsync(ThumbnailId,ThumbType,ThumbSize)
game.StarterGui:SetCore("SendNotification",{
Title = "Rebirth System";
Text = Playername .. " has earned 1 rebirth!"; -- Senior_Coolman has earned 1 rebirth!
Icon = Content
})
end)
ReplicatedStorage.GlobalReceiver.OnClientEvent:Connect(function(message)
game.StarterGui:SetCore("ChatMakeSystemMessage",{
Text = "[GLOBAL ANNOUNCEMENT]: " .. message;
Font = Enum.Font.Cartoon;
Color = BrickColor.new("Really red").Color
})
end)
If you think there is a solution for this, please let me know! Thank you!
(EDIT 1 YEAR LATER: I forgot to put down how I fixed it, so here is the fixed version of the script which will hopefully help. This was occuring in the NotificationHandler script mentioned above )
local replicatedStorage = game.ReplicatedStorage
local rebirth = replicatedStorage.Rebirth
local messagingService = game:GetService("MessagingService")
function rebirth.OnServerInvoke(plr)
if plr.leaderstats.Cash.Value >= 5000 then
plr.leaderstats.Cash.Value = 0
plr.leaderstats.Rebirths.Value = plr.leaderstats.Rebirths.Value + 1
game.ReplicatedStorage.RebirthMessage:FireAllClients(plr.Name)
return "Rebirthed"
else
return "NotEnough"
end
end
messagingService:SubscribeAsync("GlobalMsg",function(globalMessage)
print(globalMessage.Data)
replicatedStorage.GlobalReceiver:FireAllClients(globalMessage.Data)
end)
function serverEventGlobalSend(player, msg)
messagingService:PublishAsync("GlobalMsg",tostring(msg))
end
replicatedStorage.GlobalSender.OnServerEvent:Connect(serverEventGlobalSend)