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

Why does the script activate when I press "L" while typing in chat?

So I have made this script that activates gates when the user presses "L" on their keyboard and overall it works but whenever they're typing in chat and happen to use the letter "L" the gates activate. Why does this happen and how do I fix this?

Script:

local UserInputService = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Mouse = Player:GetMouse()
local FirstEnabled = true
local SecondEnabled = false
local ThirdEnabled = false
local FourthGateEnabled = false
local FifthGateEnabled = false
local SixthGateEnabled = false 
local SeventhGateEnabled = false
local EighthGateEnabled = false
local WS = 20
local HS = 100

UserInputService.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.L then 
		
		if FirstEnabled then 
		FirstEnabled = false 
		local OGWS = Player.Character.Humanoid.WalkSpeed 
		SecondEnabled = true 
		script.First:FireServer()
		spawn(function()
			wait(60)
			script.First:FireServer()
			FirstEnabled = true
			SecondEnabled = false
			ThirdEnabled = false
			FourthGateEnabled = false
			FifthGateEnabled = false
			SixthGateEnabled = false
			SeventhGateEnabled = false
			EighthGateEnabled = false
			Player.Character.Humanoid.WalkSpeed = WS
			Player.Character.Humanoid.MaxHealth = HS
		end)
		
		else if SecondEnabled then 
		ThirdEnabled = true 
		SecondEnabled = false
		script.Second:FireServer()
		spawn(function()
			wait(60)
			script.ddps:FireServer()
			FirstEnabled = true
			SecondEnabled = false
			ThirdEnabled = false
			FourthGateEnabled = false
			FifthGateEnabled = false
			SixthGateEnabled = false
			SeventhGateEnabled = false
			EighthGateEnabled = false 
						Player.Character.Humanoid.WalkSpeed = WS
			Player.Character.Humanoid.MaxHealth = HS
		end)
			
		
		else if ThirdEnabled then 
		FourthGateEnabled = true 
		ThirdEnabled = false
		script.Third:FireServer()
				spawn(function()
			wait(60)
			script.ddps:FireServer()
			FirstEnabled = true
			SecondEnabled = false
			ThirdEnabled = false
			FourthGateEnabled = false
			FifthGateEnabled = false
			SixthGateEnabled = false
			SeventhGateEnabled = false
			EighthGateEnabled = false 
						Player.Character.Humanoid.WalkSpeed = WS
			Player.Character.Humanoid.MaxHealth = HS 
		end)
		
		else if FourthGateEnabled then 
		FifthGateEnabled = true
		FourthGateEnabled = false
		script.Fourth:FireServer()
				spawn(function()
			wait(60)
			script.ddps:FireServer()
			FirstEnabled = true
			SecondEnabled = false
			ThirdEnabled = false
			FourthGateEnabled = false
			FifthGateEnabled = false
			SixthGateEnabled = false
			SeventhGateEnabled = false
			EighthGateEnabled = false 
									Player.Character.Humanoid.WalkSpeed = WS
			Player.Character.Humanoid.MaxHealth = HS 
		end)
		
		else if FifthGateEnabled then 
		SixthGateEnabled = true 
		FifthGateEnabled = false
		script.Fifth:FireServer()
				spawn(function()
			wait(60)
			script.ddps:FireServer()
			FirstEnabled = true
			SecondEnabled = false
			ThirdEnabled = false
			FourthGateEnabled = false
			FifthGateEnabled = false
			SixthGateEnabled = false
			SeventhGateEnabled = false
			EighthGateEnabled = false 
									Player.Character.Humanoid.WalkSpeed = WS
			Player.Character.Humanoid.MaxHealth = HS 
		end)
		
		else if SixthGateEnabled then 
		SeventhGateEnabled = true
		SixthGateEnabled = false 
		script.Sixth:FireServer()
				spawn(function()
			wait(60)
			script.ddps:FireServer()
			FirstEnabled = true
			SecondEnabled = false
			ThirdEnabled = false
			FourthGateEnabled = false
			FifthGateEnabled = false
			SixthGateEnabled = false
			SeventhGateEnabled = false
			EighthGateEnabled = false 
									Player.Character.Humanoid.WalkSpeed = WS
			Player.Character.Humanoid.MaxHealth = HS 
		end)
		
		else if SeventhGateEnabled then 
		EighthGateEnabled = true 
		SeventhGateEnabled = false 
		script.Seventh:FireServer()
				spawn(function()
			wait(60)
			script.ddps:FireServer()
			FirstEnabled = true
			SecondEnabled = false
			ThirdEnabled = false
			FourthGateEnabled = false
			FifthGateEnabled = false
			SixthGateEnabled = false
			SeventhGateEnabled = false
			EighthGateEnabled = false 
									Player.Character.Humanoid.WalkSpeed = WS
			Player.Character.Humanoid.MaxHealth = HS 
		end)
		
		else if EighthGateEnabled then
		EighthGateEnabled = false 
		script.Eighth:FireServer()
		spawn(function()
			wait(60)
			script.ddps:FireServer()
			FirstEnabled = true
			SecondEnabled = false
			ThirdEnabled = false
			FourthGateEnabled = false
			FifthGateEnabled = false
			SixthGateEnabled = false
			SeventhGateEnabled = false
			EighthGateEnabled = false 
									Player.Character.Humanoid.WalkSpeed = WS
			Player.Character.Humanoid.MaxHealth = HS 
		end)
		
									end
								end
							end
						end
					end
				end
			end
		end
	end
end)

GIF of what I mean if you're confused: https://gyazo.com/7db63d7d86068dd490ae401f39528da6

1 comment

0

you ddiint check if was in a gui

1 answer

Cause the keyboard fucntion is on L when you press it you can go into script and change hr L keyboard to something else!

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