My game has a surface gui on a part that connects to a webhook which sends that message, but it is sending it multiple times (4+). I looked through my code for errors, but I couldn’t find any so I came here lol.
Script inside the textbox:
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/keykeykeyitykey", Data)
cooldown = true
wait(3)
cooldown = false
end)
end
end)
Script inside server script service for filtering that text:
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)
Script inside of startergui:
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)
end)
I tweaked it a little bit to optimize, but it still sends multiple