Basically, I have a script in a roblox game which gets text input, a script to put this input through a filter, and a script to send this input to the webhook, however it is being sent multiple times, which increases with every message. Is there any way to fix this?
LocalScript:
local rem = game.ReplicatedStorage:WaitForChild("Server")
local rem2 = game.ReplicatedStorage:WaitForChild("Client")
local TextService = game:GetService("TextService")
local textbox = game.Workspace:WaitForChild("Part").SurfaceGui.TextBox
local player = game.Players.LocalPlayer
local userid = player.UserId
local filter1 = game.ReplicatedStorage:WaitForChild("FilterServer")
local filter2 = game.ReplicatedStorage:WaitForChild("FilterClient")
local filter3 = game.ReplicatedStorage:WaitForChild("FilteredBAD")
local earlymessage = ""
local message = ""
textbox.FocusLost:Connect(function(inputObj)
earlymessage = textbox.Text
print(userid)
tostring(earlymessage)
print(earlymessage)
filter1:FireServer(earlymessage)
filter2.OnClientEvent:Connect(function(msg)
message = msg
rem2:FireServer(message)
wait(3)
end)
end)
filter3.OnClientEvent:Connect(function(text)
textbox.Text = text
end)
Filter Script:
local rem = game.ReplicatedStorage:WaitForChild("FilterServer")
local rem2 = game.ReplicatedStorage:WaitForChild("FilterClient")
local rem3 = game.ReplicatedStorage:WaitForChild("FilteredBAD")
local TextService = game:GetService("TextService")
local finalmessage = ""
local cooldown = false
rem.OnServerEvent:Connect(function(player, startmessage)
if cooldown == false then
local success, errorMessage = pcall(function()
tostring(startmessage)
local userid = player.UserId
finalmessage = TextService:FilterStringAsync(tostring(startmessage), userid):GetNonChatStringForBroadcastAsync()
rem3:FireAllClients(finalmessage)
tostring(finalmessage)
rem2:FireClient(player, finalmessage)
print(finalmessage)
cooldown = true
wait(4)
cooldown = false
end)
if not success then
warn("Error filtering text:", errorMessage)
rem3:FireAllClients()
end
end
end)
Message send script:
local http = game:GetService("HttpService")
local cooldown = false
local rem1 = game.ReplicatedStorage:WaitForChild("Server")
local rem2 = game.ReplicatedStorage:WaitForChild("Client")
script.Parent.Parent.Parent.Send.SendGui.TextButton.MouseButton1Click:Connect(function()
if cooldown == false then
rem1:FireAllClients()
print("client fired")
rem2.OnServerEvent:Connect(function(player, message)
print(message)
local Data = {
["content"] = message
}
Data = http:JSONEncode(Data)
print(Data)
http:PostAsync("https://webhook.lewisakura.moe/api/webhooks/keygerekiki", Data)
cooldown = true
wait(3)
cooldown = false
end)
end
end)
I have been trying for hours to fix this with no help. I expect it to only send one message, and it only does that the first message, then keeps increasing.
Looks like you're connecting more event handlers whenever you receive either a FocusLost or mouse click. So, yeah, that'll just increase over time.