What I would do is when you detect someone used Control V connect a .chatted event to them and wait for the message. You can then use the message parameter to log what the player sent.
You can just bind an action like crouch to CTRL key and when they crouch constantly, you can know that they are copy pasting.
If you want it to be more clear, you can use tick() and UserInputService, check the V key until timeout. If you don’t use this, they can get warned wrongly. Keep in mind GameProcessedEvent needs to be true in order to this method to work.
Will it work if I will just copy the existing function in the main module and edit it?
Disagree—players will use it to actually be able to crouch.
You have to press v while the control key is held. If you release the control key you can’t use the shortcut anymore. It is not a matter of “if you release control and don’t press v in a certain amount of time the shortcut stops working”.
I think you haven’t really played a game using this method. It’s easy to seperate normal crouching and copy pasting with it.
That’s my bad.
You need to get the currently focused text box using UserInputService:GetFocusedTextBox
. If you want this solely for the chat box then just get it by
local client = game:GetService("Players").LocalPlayer
local chat_box = client.PlayerGui.Chat:FindFirstChild("ChatBar", true)
local old_text = chat_box.Text
chat_box:GetPropertyChangedSignal("Text"):Connect(function()
local new_text = chat_box.Text
if #new_text - #old_text > 1 then
print("Player copy-pasted")
end
old_text = new_text
end)
If it’s while the player is in a focused text box then yes this can work. But a crouch feature doesn’t fit all games.
Here’s the function:
local PlayerCommand = Message:gmatch("%w+")()
if not PlayerCommand then
return
else
PlayerCommand = PlayerCommand:lower()
end
local PlayerPrefix = Message:sub(1,1):lower()
local PlayerPermission = returnPermission(Player)
if PlayerPermission <= 0 then
-- Truncate the message for non-admins
-- If admins are sending excessively long messages in your game, you have a different problem.
Message = Message:sub(1,1000)
end
local Command = CommandsDictionary[PlayerCommand]
if Command then
local CommandName = Command[1]
local CommandPrefix = Command[2]
local CommandFunction = Command[3]
local CommandPermission = Command[4]
if (PlayerCommand == CommandName) then
if (PlayerPermission >= CommandPermission) then
local ActionCommandUsed = (CommandPrefix == sysTable.actionPrefix and PlayerPrefix == CommandPrefix) and Message:sub(2)
local RegularCommandUsed = ((#CommandPrefix == 0 and PlayerCommand:sub(1,1) == PlayerPrefix) and Message) or ((PlayerPrefix == CommandPrefix) and Message:sub(2))
local MessageWithoutPrefix = ActionCommandUsed or RegularCommandUsed or nil
if MessageWithoutPrefix then
local Arguments = {}
table.insert(Arguments, Player)
for Segment in string.gmatch(MessageWithoutPrefix, "%S+") do
if not Arguments[2] then
table.insert(Arguments,Segment:lower())
else
table.insert(Arguments,Segment)
end
end
local Success,Error = pcall(function()
CommandFunction(Arguments)
end)
if Success == true then
local cleanedMessage
local Cleaned,newData = cleanUserData(Message,Player,false)
if Cleaned and newData then
cleanedMessage = newData
elseif not Cleaned then
cleanedMessage = newData
end
if cleanedMessage then
pluginEvent:Fire("Admin Logs",{Player,newData})
else
addLog(sysTable.Logs,{Sender = Player,Bypass = true,Data = '(super safechat) executed "'..tostring(b[1] or "???")..'"',Tag = true})
return
end
addLog(sysTable.Logs,{Sender = Player,Data = cleanedMessage}) -- Store the filter instance once we can use it properly.
elseif Error ~= nil then
addLog(sysTable.debugLogs,'"'..Arguments[2]..'"| Error: '..Error)
essentialsEvent:FireClient(Player,'Message','Function Error','Name: "'..Arguments[2]..'"\n'..Error)
end
end
end
end
end
if Chatted == true then
local cleanedMessage
local function Redo()
local Succ,Msg = pcall(function()
cleanedMessage = chatService:FilterStringForBroadcast(Message,Player)
end)
if not Succ then
wait(1)
Redo()
end
end
Redo()
I have no idea how to modify it though.
Here’s the second one:
Player.Chatted:connect(function(Message)
onChatted(Message,Player,true)
end)
spawn(function()
pcall(function()
for otherPlayer,nameData in next,sysTable.localNames do
local filteredName
local Cleaned,newData = cleanUserData(nameData.Data,nameData.Sender,Player)
if Cleaned then
filteredName = newData
end
if filteredName then
for c,d in next,playerService:GetPlayers() do
essentialsEvent:FireClient(Player,'Local Name',otherPlayer,filteredName)
end
end
end
end)
end)
I still can’t understand how to do it. It is very confused for me as I never used chatted events.
You actually don’t have to use the chatted events (I really need to stop using Dev forum at 4 am)
You could easily use the code @sjr04 has provided and get the copy pasted text using some string manipulation. Then its up to you with what you want to do with it send it to the server and have it be displayed in some GUI somewhere. Im pretty sure Basic Admin essential has a way to add a custom command in. So you could just add in your new custom command that GUI. Best of luck
Lol, thank you! You too!
Just adding on, you shouldn’t rely on comparing the old string with the new string. The problem is that fast typers could accidently press 2 keys (or more) at the same time, therefore, the game will consider they copy pasted. This could happen as well if Roblox is somewhat lagging, not well synced with the keyboard, or if it’s a problem keyboard, etc.
You should rely on incapz’s method, (aka ctrl cc + ctrl v), as it is more accurate. Whatsoever, it won’t work on mobile. The comparing string method doesn’t work as well on mobile. It might work on Studio when using the phone screen, but it actually doesn’t work if you try on an actual mobile for some reasons.
Well, I don’t think there will be a lot of mobile users as our interview center very laggy for them and we didn’t release mobile version yet soo.
Nope, that won’t work for BAE 2.0
The chat bar and UserInputService can only be detected in a local script. You will have to utilize remote events.
Yes, I know. I did it but it still doesn’t work.
It does, that’s the method I’m using to use make my CPLogs. Here’s a quick runway:
- Use InputService to know when the player presses CTRL and V in a local script.
- Fire a RemoteEvent to the server.
- The server listens to the event, and waits for the player to chat.
- Once the player chatted, save it somewhere. (in a table)
Use a BA plugin to display a list with what you saved. I won’t show my script because it really isn’t needed. If you’re a programmer and are experienced in how BA works, you should be completely fine making it yourself with the help provided.
PS: You might wanna protect your RemoteEvent somehow. You don’t want exploiters to spam fire it.
Thank you @lyoorubyjane, @sjr04, @kylepo99 and @Aerodymier for helping me. This question is now solved!
What’s the full script and how do I add it into my game? I’m a new developer…
You shouldn’t be coming here looking for the full script, instead you should probably do the following steps.
Hire a developer if needed, this is the easy way out BUT is quite expensive.
Learn LUA and how BAE works, I wouldn’t go looking for how to make copy paste logs if you’re a beginner.
There are parts of the script above, would recommend putting them together and experimenting or something like that.