So here is the code, I will explain under it:

local player = game.Players.LocalPlayer
local UIS = game:GetService("UserInputService")
local taps = 0
local debounce = false

animsStop = {"Dragging2", "KillDragging"}

UIS.InputBegan:connect(function(key, GPE)
	if key.KeyCode == Enum.KeyCode.T and not GPE and debounce == false then
		debounce = true
		taps = taps + 1
		script.Parent.TextLabel.Text = "Struggle: " ..80 - taps 
		print(taps)
		if taps >= 80 then
				player:FindFirstChild("Player_Status").Carried.Value = false
				player.Character.Humanoid.WalkSpeed = 10
				player.Character.Humanoid.Health = 75
			--	_G.SurvivorAnim:Stop()
				if player.Character["Left Leg"].DragJoint then
					player.Character["Left Leg"].DragJoint:Destroy()
				end
				for i, v in pairs(game.Players:GetPlayers()) do
					v:FindFirstChild("Player_Status").Carrying.Value = false
					for i, anim in pairs(v.Character.Humanoid:GetPlayingAnimationTracks()) do
						for i, stop in pairs(animsStop) do
							if anim.Name == stop then
								anim:Stop()
							end
						end
					end
				end
				script.Parent:Destroy()
		end
		debounce = false
		end
end)

So basically what this all does is, taps is the number of saved times the player has tapped the T key. It records it every time and once taps is greater than or equal to 80 it sets some values to false and all that stuff. Basically what is happening is the input is being registered twice and it kind of breaks the whole script somehow and I am out of ideas on how to fix it. I thought adding that debounce would fix it but, I guess I thought wrong.

3 comments

0

You're using "InputBegan". Try use an event that fires when the player releases the key - Holding a key may fire multiple times

1

InputBegan doesn't fire multiple times when a key is held.

0

I did InputBegan and InputEnded and both still are putting out the same results. InputBegan doesn't fire multiple times when a key is held.