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

How do I create a message in Filtering Enabled?

A while back I created a script when the player said "bill nye" a message instance would be created saying "the science guy!" which would then delete after 3 seconds. It was for practice then, and today I learned how to use RemoteEvents in Filtering Enabled, so I decided to use it to practice again. When I scripted it, I noticed that it did not work at all. No output, no signs of working in any way. How can I fix this without using RemoteFunctions?

Where everything is located: BillEvent (LocalScript) - StarterPack BillEvent (RemoteEvent) - ReplicatedStorage BillEvent (Script) - Workspace Yes, I am aware it is not very smart to have all of them under the same name, it is my preference however. Apologies for any inconveniences.

What the scripts have in them: BillEvent (LocalScript) - Starterpack:

script.Parent.Parent.Chatted:Connect(function()
	game.ReplicatedStorage.BillEvent:FireServer()
end)

BillEvent (Script) - Workspace:

game.ReplicatedStorage.BillEvent.OnServerEvent:Connect(function(player, msg)
	if msg == "bill nye" then
		local m = Instance.new("Message")
		m.Parent = game.Workspace
		m.Text = "the science guy!"
		wait(3)
		m:Destroy()
	end
end)

How can I fix this issue without using RemoteFunctions? (Preferably using any kind of script [excluding module] and RemoteEvents.) Thank you for your time and interest in advance!

1 comment

2

Do not handle the chatted event on the client!

1 answer

You can actually handle the chatted event from the server, and it's even more recommended to do so. You don't need any sort of local script, so instead in the server script just connect a PlayerAdded event to the function.

game:GetService("Players").PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(msg)
		if msg == "bill nye" then
			local m = Instance.new("Message")
			m.Parent = game.Workspace
			m.Text = "the science guy!"
			wait(3)
			m:Destroy()
		end
	end)
end)

Note: If this was implemented in an actual game players would be able to spam "bill nye" and everyone would see the message blocking their screen. If you were to actually use this I would recommend handling some things from the client.

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