I’m making a script that works in every server. This script will fire an event, that event makes a ChatMessage.
However one of the arguments, if missing, it won’t have a custom color, the script makes it so if there’s no argument, it just puts the color as red. So I decided to try making it work, but I get the error:
ServerScriptService.Moderation.WebHooks:126: attempt to index nil with ‘Data’
Scripts:
function runSCWin(towerName,serverMessage)
script.SM.Value = serverMessage
script.TowerN.Value = towerName
print(script.SM.Value)
print(script.TowerN.Value)
game:GetService("MessagingService"):PublishAsync("SCWin",{m=tostring(script.SM.Value),m2=tostring(script.TowerN.Value)})
end
game:GetService("MessagingService"):SubscribeAsync('SCWin',function(mdata,m2data)
local message = mdata.Data.m
local message2 = m2data.Data.m
if message and message2 then
print("Message Recieved! "..message)
print("Message Recieved! "..message2)
local v2 = true
game.ReplicatedStorage.ServerMessage:FireAllClients(message,message2,sc)
end
end)
PS: It errors when trying to add/use mdata2, but works with mdata somehow