Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Called on client not server!? [STILL UNANSWERED]

local Text = script.Parent.Parent.TextBox.Text
		if Text ~= "Type here"
			then
			local Text2 = Text.."k"
			local FilteredT = game.Workspace.RemoteFunctions.FilterName:InvokeServer(Text2)
			local StringLength = string.len(FilteredT)			
			local FilteredText = string.sub(FilteredT, 1, StringLength-1)
			if string.find(FilteredText,"#",1,false) ~= nil then
				script.Parent.Text = "Type here"
			else
				script.Parent.Parent.Visible = false
				end
		end

^ Local script on the client

script.Parent.OnServerInvoke = function(Player,Text)
	return game:GetService("Chat"):FilterStringForBroadcast(Text, Player)
end

^On the server

Any ideas why it is telling me that I am using Chat:FilterStringForBroadcast on the client when I am clearly using it on the server?? Thanks!

3 comments

2

What is the exact error you are getting?

0

The exact error is: ChatService:FilterStringForBroadcast called on a client, only works from server.

0

You're returning it to the client, which then makes it run by the client. Try defining it as a local, and sending the local.

1 answer

It's probably being awfully pedantic. Try:

script.Parent.OnServerInvoke = function(Player,Text)
   local x = game:GetService("Chat"):FilterStringForBroadcast(Text, Player)
	return x
end

Otherwise, you might need to extend the contents of the OnServerInvoke function into functions within the client-sided script, ROBLOX really is being over the top (it's not your fault)!.

This discussion is preserved as it was. New answers, comments, and votes are closed.