Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Script activating while typing toggle key T how do i fix?

I wanna make the notifaction and script not activating while typing the toggle key is T

local toggleKey = Enum.KeyCode.T -- the key to press to toggle the feature local enabled = false -- whether the feature is currently enabled local notificationDuration = 1 -- the duration of the notification in seconds local iconImage = "rbxthumb://type=Asset&id=11151804229&w=150&h=150" -- the ID of the image to use as the icon

local function onKeyPress(inputObject) if inputObject.KeyCode == toggleKey then enabled = not enabled -- toggle the feature if enabled then game:GetService("StarterGui"):SetCore("SendNotification", { Title = "Anti-Lock", Text = "Enabled-rio.#3943.", Duration = notificationDuration, Icon = iconImage }) else game:GetService("StarterGui"):SetCore("SendNotification", { Title = "Anti-Lock", Text = "Disabled-rio.#3943.", Duration = notificationDuration, Icon = iconImage }) end end end

game:GetService("UserInputService").InputBegan:Connect(onKeyPress)

game:GetService("RunService").Heartbeat:Connect(function() if enabled then local abc = game.Players.LocalPlayer.Character.HumanoidRootPart.Velocity game.Players.LocalPlayer.Character.HumanoidRootPart.Velocity = Vector3.new(1,1,1) * (2^16) game:GetService("RunService").RenderStepped:Wait() game.Players.LocalPlayer.Character.HumanoidRootPart.Velocity = abc end end)

1 answer

✓ Accepted answer

Edit your onKeyPress function to also include if the engine processed the input. So change the local function onKeyPress(inputObject) to for example local function onKeyPress(inputObject, gameProcessed).

Then, put this piece of code directly under that line if gameProcessed then return end.

It should look like this:

local function onKeyPress(inputObject, gameProcessed)
	if gameProcessed then return end
	-- Your normal code here

The gameProcessed variable will tell you if Roblox has already done something with that input (for example, used it as a movement key or while you're typing). The other line checks if roblox has already done something with the input and if so it will not continue with the code.

This discussion is preserved as it was. New answers, comments, and votes are closed.