Unable to cast value to Object? Filtering Text

Hi, I want to make a part with a TextBox on it. When You Press Enter on another a Screen Gui, but it will filter it if it is a bad/inappropriate. Sorry If This Sounds Confusing!

When I Test it, it just says, “Unable to cast value to Object” on line 6 in the output, and I don’t know how to solve this.

I’ve tried a tutorial, but it still didn’t work, I’m thinking I maybe typed it wrong. I tried putting it in a local script and Sever Script, and placing it under part.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

(Under Part)

local ScreenUi = game.StarterGui.ScreenGui.Frame
local SurfaceUi = workspace.Part:WaitForChild("SurfaceGui")

game.Players.PlayerAdded:Connect(function(player)
	while wait(5) do
		local msg = game.Chat:FilterStringForBroadcast(ScreenUi.GameName.Text, SurfaceUi.GameNamePart.Text, player)
		ScreenUi.GameName.Text = msg
		SurfaceUi.GameNamePart.Text = ScreenUi.GameName.Text
	end
end)

I can also show you what I have in the Explorer to make it more clear.

Thank You!

1 Like

You have 3 args instead of 2.

1 Like

Wow thanks, I’m still learning slowly so this helped me a lot!

1 Like