function filterMessage(player, text, fromPlayerId)
local TextService = game:GetService("TextService")
local filteredText = ""
local success, errorMessage = pcall(function()
filteredTextResult = TextService:FilterStringAsync(text, fromPlayerId)
end)
if not success then
warn("Error filtering text:", text, ":", errorMessage)
-- Put code here to handle filter failure
end
end
function sendMessage(message, player)
script.Parent.Messages.NoMessages.Visible = false
local movmentPosition = -30 -- change - to 30 if you want it going down, but keep it minus for up. Change value accordingly for how far up/down you want it.
for _,v in pairs(script.Parent.Messages.Messages:GetChildren()) do -- change to where your notifcations are located
if v:IsA('TextLabel') then -- change this to what you are using as a notification
local msg = script.Parent.Messages.Template:Clone()
msg.Text = message
msg.Name = tostring(player)..": "..message
msg.BackgroundTransparency = 0
v.Position = v.Position + UDim2.new(0,0,movmentPosition,0)
end
end
end
game.ReplicatedStorage.SendStaffMessage.OnServerEvent:Connect(function(message, playerId)
filterMessage(message, playerId)
sendMessage(filteredTextResult)
end)
It would help a lot if you said which line was throwing the error in the output window. “Argument 2 Missing or Nil” means that the second argument of the called function, such as Vector3.new(x,y,z) isn’t there, for example if you tried to do Vector3.new(1). Once you get the line that’s throwing the error, you could easily figure out why. For example, this shows the line the error is on as line 6 of Workspace.Script:
The first argument of OnServerEvent is the player who fired the RemoteEvent from their client. So the “message” parameter stands for the player, which is detected by the script like that. In the first line of the script, it couldn’t perceive the fromPlayerId parameter. Simply
The exact error begins with that line. warn shows the error why it is occurring. And yes, don’t forget to add this if you want to use the player in your function.