Sending tick through function on input began not working

So I have a function in input began and I send tick with a bindable event and it doesnt want to work

CODE :

u.InputBegan:Connect(function(i,t)
	if t then return end
	if i.KeyCode == Enum.KeyCode.Q and isAir then
		local Hold = tick()
		Trigger:Fire(Hold)
		Cast(m.Hit, m.Target, "LeftWebAttachment")
	end
end)

In the function Cast

Trigger.Event:Connect(function(Hold)
		if tick() - Hold <= .5 then
			print("THUNK THAT")
		else
			if math.floor(humrp.Position.y) < math.ceil(pinpoint.WorldPosition.y) + 50 then
				print("Playing Animation")
				hum:LoadAnimation(game.ReplicatedStorage.Swing1):Play()
			end
			SpawnBeam(pinpoint.WorldPosition,pinpoint, "leftweb")
			AddForce(pinpoint.WorldPosition,pinpoint,game.Workspace:WaitForChild("leftweb"))
		end
	end)

You’re only comparing it every time the event is fired , you might want to use .InputEnded and check the tick and fire the event accordingly

local hold

function InputBegan()
    hold = tick()
end

function InputEnded()
    if ( tick() - hold ) > 0.5 then 
        Event:Fire()
    end
end
1 Like

You are:

t here is gameprocessed and It returns true but you detect if its true and return just do

u.InputBegan:Connect(function(i,t)
	if not t then return end
	if i.KeyCode == Enum.KeyCode.Q and isAir then
		local Hold = tick()
		Trigger:Fire(Hold)
		Cast(m.Hit, m.Target, "LeftWebAttachment")
	end
end)

Im doing that because I dont want players to type while trying to fire this, that most definitely is not the problem

That is clearly the problem even when player is doing everything clearly you are still returning it

You’re incorrect here.

if not t then return end

GameProcessed is true, whenever the game has processed the input.
It’ll be true, say when the player is typing in a TextBox.

So when you are doing not t, when the game hasn’t processed the input, it’ll return true.
This means that the check will pass, and now return, making the script end there.

Edit: last explanation why it wouldn’t work is a bit incorrect, so I edited it to be a bit more thorough and clear.

Ill try this you actually understand the problem thanks lots

1 Like

Thank you for understanding, it was clearly not the problem

1 Like

Thanks for revising my post and clearing doubts!