This issue is happening on the server script of a function that displays a message to another user, which therefore requires filtering. However when it gets to this line it throws out the error:

Unable to cast value to Object, Line 9

Script:

local onRecievingWarning = game.ReplicatedStorage.FilterWarning


onRecievingWarning.OnServerEvent:connect(function(player, message, victim)
	print("Triggered!")
	player = victim
	print(player)  --Used to make sure the I didn't mess up the order on the client side
	local filteredText = game:GetService("Chat"):FilterStringForBroadcast(player, message)
	local warngooey = game.ReplicatedStorage:WaitForChild("TPSWarnGUI"):Clone()
	warngooey.Enabled = true
	warngooey.LoginForm.Rsn.Text = filteredText
	warngooey.Parent = game.Players[player].PlayerGui
	wait(3)
	game.Players[player].PlayerGui.TPSWarnGUI:Destroy()
end)

4 comments

0

i guess you could try without the wait for child

0

You have mixed up the order for FilterStringForBroadcast, it needs the string message then the player.

0

Still getting the error

0

Are you sending the player object on the client side?