So I have 2 scripts one sets a boolvalue to true while holding down "ctrl" and one that only works when the value is set to true and it activates if you click "v" aswell, it kills the player.

script1:
Player = game.Players.LocalPlayer
Mouse = Player:GetMouse()
Mouse.KeyDown:connect(function(key)
if key:byte() == 50 then
print("keypressed")
script.Value.Value = true
end
end)
Mouse.KeyUp:connect(function(key)
if key:byte() == 50 then
script.Value.Value = false
print("keyunpressed")
end
end)
script2:
Player = game.Players.LocalPlayer
Mouse = Player:GetMouse()
Mouse.KeyDown:connect(function(key)
if script.Parent.AntiCP.Value.Value == true then
if key:byte() == 118 then
repeat wait() until Player.Character
Character = Player.Character
Character.Humanoid.Health = 0
print("keypressed")
end
end
end)

It will work fine when I don't type in the chat, but while trying to copy paste in the chat it won't work.

8 comments

0

Please format your code properly. Additionally, what is the point of trying to stop someone from copying and pasting?

0

It is for my wand system I don't want people copy pasting spells to cast faster.

0

I edited it so you can read it, can you help?

0

You should really indent your code. Also, Mouse.KeyDown and Mouse.KeyUp are deprecated. Also RBXScriptSignal:connect() is deprecated, use RBXScriptSignal:Connect(), also use local Character = Player.Character or Player.CharacterAdded:Wait(), also call Instance:WaitForChild() for the character's humanoid. Use UserInputService instead of mouse events.

0

And an exploiter can still copy and paste if they want to, you wouldn't be able to stop that, just worth saying.

0

Can you help me solve my problem please, Instead of telling me different methodsthat will give me the exect same result, I don't want to sound rude, but I would like to know why this code won't work while typing in the chat.

0

Hi why would I call Instance:WaitForChild() for character's humanoid, please tell me because it might teach me something

0

Adven it is to find the character's humanoid the wait for child thingy is for waiting for humanoid to be inserted into the character it prevents errors sometimes