Nothing wrong with it. I was just saying that with a Send button you can be sure that the “message” ServerRemoteListener is only triggered once and you can close the FireEventDeb when that happens. You said that event is firing multiple times, I guess
Sorry, but I dont know why your remote SendMessage or your remote RecieveMessage are firing twice. Should be a wrong setup on your side that we dont know…
Or maybe, because you are cloning the template when sending message and when receiving the message too, and you are confusing that both are from both events.
I could check your script later if I have some free time.
And try to keep a single post for each issue you are facing, no need to duplicate posts…:
Narrowed down.
Coming from the player recieving the message.
When you print the message sent after the click , its one string Therefore there wasnt double clicks.
When you print the message recieved in the server , its one string Therefore the event wasnt fired twice
When you print the message the player recieves on client script , its two strings.
The code:
game:GetService("ReplicatedStorage"):WaitForChild("RecieveMessage").OnClientEvent:Connect(function(From, Message)
if Deb == true then return end
Deb = true
local To = templates:WaitForChild("RecievingMessage"):Clone()
To.Text = Message
To.Parent = game.Players.LocalPlayer.PlayerGui.Phone.Frame.Phone.Main.PlayerContacts:FindFirstChild(string.lower(From.Name)).Recieve
To.Visible = true
print(To.Text)
-- Don't mind this, this is for indicating player got sent a message
if game.Players.LocalPlayer.PlayerGui.Phone.Frame.Phone.Main.PlayerContacts:FindFirstChild(string.lower(From.Name)).Visible == false then
game.Players.LocalPlayer.PlayerGui.Phone.Frame.Phone.Main.Messaging.Contacts:FindFirstChild(string.lower(From.Name)).User.TextColor3 = Color3.fromRGB(255, 42, 46)
game.Players.LocalPlayer.PlayerGui.Phone.Frame.Phone.Main.PlayerContacts:FindFirstChild(string.lower(From.Name)):GetPropertyChangedSignal("Visible"):Connect(function()
if game.Players.LocalPlayer.PlayerGui.Phone.Frame.Phone.Main.PlayerContacts:FindFirstChild(string.lower(From.Name)).Visible == true then
game.Players.LocalPlayer.PlayerGui.Phone.Frame.Phone.Main.Messaging.Contacts:FindFirstChild(string.lower(From.Name)).User.TextColor3 = Color3.fromRGB(255,255,255)
end
end)
end
--
task.wait(2)
Deb = false
end)
--Server script if needed
RS:WaitForChild("SendMessage").OnServerEvent:Connect(function(Player, From, Message, To)
if Message == "" then
return
end
local messageObject = getTextObject(Message, From.UserId)
if not messageObject then
return
end
local filteredMessage = getFilteredMessage(messageObject, From.UserId)
RS:WaitForChild("RecieveMessage"):FireClient(game:GetService("Players"):FindFirstChild(To), From, filteredMessage)
print(filteredMessage .. "server")
end)
This was a solution because I realized the recieving script was under the direct messages of the player thats being sent the message. Where the template duplicated twice. One for the player, one for the recievingp layer