Feedback system suddenly not working

Since people were sending this to my discord server via feedback:

You have not reached the minimum of ## characters!

I decided to make change up the system so people couldn’t send ^^ to the discord server.

Instead of that message going to the textbox I made it go to a whole different textlabel.

The old script looked like this:

local min = 10

local deb = false
script.Parent.MouseButton1Click:Connect(function()
	if not deb then
		deb = true
		if #script.Parent.Parent.Feedback.Text >= min then
			local msg = script.Parent.Parent.Feedback.Text
			script.Parent.Parent.Feedback.Text = "Sending..."
			local response = game.ReplicatedStorage.RemoteEvents.Feedback:InvokeServer(msg)
			print("Invoked")
			script.Parent.Parent.Feedback.Text = response
			wait(5)
			print("Wait done")
			if script.Parent.Parent.Feedback.Text == response then
				script.Parent.Parent.Feedback.Text = ""
			end
			deb = false
		else
			script.Parent.Parent.Feedback.Text = "You have not reached the minimum of "..min.." characters!"
			wait(5)
			deb = false
		end
	end
end)

or something like that.

Here is the new script:

local min = 10

local deb = false
script.Parent.MouseButton1Click:Connect(function()
	if not deb then
		deb = true
		if #script.Parent.Parent.Feedback.Text >= min then
			local msg = script.Parent.Parent.Feedback.Text
			script.Parent.Parent.Feedback.Text = ""
			script.Parent.Parent.SubmitMessage.Text = "Sending..."
			local response = game.ReplicatedStorage.RemoteEvents.Feedback:InvokeServer(msg)
			print("Invoked")
			script.Parent.Parent.SubmitMessage.Text = response
			wait(5)
			print("Wait done")
			if script.Parent.Parent.SubmitMessage.Text == response then
				script.Parent.Parent.SubmitMessage.Text = ""
			end
			deb = false
		else
			script.Parent.Parent.Feedback.Text = ""
			script.Parent.Parent.SubmitMessage.Text = "You have not reached the minimum of "..min.." characters!"
			wait(5)
			deb = false
		end
	end
end)

(this is a local script btw)

Maybe there is something wrong with this server script:

local HS = game:GetService("HttpService")
local chatService = game:GetService("Chat")

local webhookURL = "url"
local filteringAndSend = game.ReplicatedStorage.RemotesEvents.Feedback

function filteringAndSend.OnServerInvoke(plr, msg)
	local filtered = chatService:FilterStringForBroadcast(msg, plr)
	
	local payload = HS:JSONEncode({
		content = filtered,
		username = "Submitted by: "..plr.Name
	})
	
	HS:PostAsync(webhookURL, payload)
	return "Feedback recieved!"
end

I had just recopied the webhook url and it was literally the same.

Could I use table.unpack({"You don't want to send this", "You don't want to send this either"}) and make it like this?

if script.Parent.Parent.Feedback.Text ~= table.unpack({"You don't want to send this", "You don't want to send this either"}) then
    --code
end

btw here is my set up:
Screen Shot 2020-08-15 at 6.32.22 PM
and a script in ServerScriptService.

2 Likes

You shouldn’t show your webhook here since people could just spam it themselves using HttpService.
Also, you should be checking if the string is more than 10 characters on the server too, since people could fire your remote.

You should also make script.Parent.Parent.Feedback a variable, since you’re using it very often. Using variables makes things a whole lot cleaner as you don’t need to type out the same thing multiple times. It’ll also help readers understand your code better, therefore being able to help you easily.
(related: Don't repeat yourself - Wikipedia)


Hope this helped.
5 Likes

Thanks. There was a whole lot of spamming, so I just deleted the channel to start over.

I’m currently doing the things you told me to, since I was new to discord at the time I was making it, I just rushed the tutorial because I was so happy to finally have discord (yes, I was), so I didn’t put in time to make things variables.

Also this is what happens: The feedback is over 10, so then it says “Sending…” and that’s it. It just breaks at that point.

2 Likes

Done.

local HS = game:GetService("HttpService")
local chatService = game:GetService("Chat")

local webhookURL = "haha url go bye bye"
local filteringAndSend = game.ReplicatedStorage.RemotesEvents.Feedback

function filteringAndSend.OnServerInvoke(plr, msg)
	if #msg >= 10 then
		local filtered = chatService:FilterStringForBroadcast(msg, plr)
	
		local payload = HS:JSONEncode({
			content = filtered,
			username = "Submitted by: "..plr.Name
		})
	
		HS:PostAsync(webhookURL, payload)
		return "Feedback recieved!"
	else
		return "Server did not get ten characters!"
	end
end
local min = 10

local feedback = script.Parent.Parent.Feedback
local message = script.Parent.Parent.SubmitMessage

local deb = false
script.Parent.MouseButton1Click:Connect(function()
	if not deb then
		deb = true
		if #feedback.Text >= min then
			local msg = feedback.Text
			feedback.Text = ""
			message.Text = "Sending..."
			local response = game.ReplicatedStorage.RemoteEvents.Feedback:InvokeServer(msg)
			print("Invoked")
			message.Text = response
			wait(5)
			print("Wait done")
			if message.Text == response then
				message.Text = ""
			end
			deb = false
		else
			feedback.Text = ""
			message.Text = "You have not reached the minimum of "..min.." characters!"
			wait(5)
			deb = false
		end
	end
end)

Tested it, doesn’t work as I just added a few things. Must be a problem with the RemoteFunction.

wait… do you need to do

filteringAndSend.OnServerInvoke(plr, msg)

or something like that so the function runs?

1 Like

No, you would just do filteringAndSend:InvokeServer(msg).

Also, unpack returns a tuple, and you can’t compare one value to multiple values. You would have to compare it to each one.

5 Likes

ah. So the function SHOULD be running?

1 Like

Yeah, if you’re invoking the server somewhere on the client.

4 Likes

By the looks of it, it’s never getting invoked:

function filteringAndSend.OnServerInvoke(plr, msg)
	print('Invoked!')
	if #msg >= 10 then
		print('Message over than 10 characters')
		local filtered = chatService:FilterStringForBroadcast(msg, plr)
	
		local payload = HS:JSONEncode({
			content = filtered,
			username = "Submitted by: "..plr.Name
		})
	
		HS:PostAsync(webhookURL, payload)
		return "Feedback recieved!"
	else
		return "Server did not get ten characters!"
	end
end

nothing printed.

1 Like

Where’s everything in the explorer? Can you put a print in the client script before you InvokeServer? Not really sure what the issue would be.

3 Likes

Found the issue.
In the LocalScript, you wrote:
game.ReplicatedStorage.RemoteEvents.Feedback
But in the Script, you wrote:
game.ReplicatedStorage.RemotesEvents.Feedback

4 Likes

If there wasn’t an error, the Script isn’t running at all, since he said nothing was printed.

4 Likes

Maybe he had a structure like this:
image
Not sure if by “nothing printed” he meant that nothing printed in the Script, the LocalScript or both though.

@IAmPinleon Try printing something in the Script(outside of the function) and see if it prints in the output, so that you can determine whether it’s running or not.

2 Likes