InputEnded bug?

The problem here is the InputEnded and the TweenService:Create()

The tweenservice:create inside InputEnded It is executed before all the code even if it is within the condition.

--Services/Variables
local TweenService = game:GetService("TweenService")
local UserInputService = game:GetService("UserInputService")

local Cam = workspace.CurrentCamera
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local humanoid:Humanoid = char:WaitForChild("Humanoid")

local Debounce = true
local key = "LeftShift"

local TweenInfo = TweenInfo.new(
	0.5,
	Enum.EasingStyle.Linear, 
	Enum.EasingDirection.Out,
	0,
	true,
	0
)

--Fov info
local End = {FieldOfView = 70}
local Start = {FieldOfView = 115}

UserInputService.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode[key] and Debounce then
		print("Input start")
		Debounce = false
		TweenService:Create(Cam, TweenInfo, Start):Play()
		
		humanoid.WalkSpeed = 20
	end
end)

UserInputService.InputEnded:Connect(function(input)
	if input.KeyCode == Enum.KeyCode[key] and Debounce == false then
		print("Input ended")
		Debounce = true
		TweenService:Create(Cam, TweenInfo, End):Play()
		
		humanoid.WalkSpeed = 16
	end
end)

Are you positive that your not letting go of LeftShift?

Does it reset the players walkspeed aswell?
@TheDestroyer0525 oh alright haha, now you know not to make that mistake again best of luck developing!

1 Like

Well that “true” is actually the reason of my problem, I also appreciate the help

1 Like