Gun equip issues

  1. What do you want to achieve? I want the equipped value and the equipped event to change when the E key is pressed

  2. What is the issue? When the E key is pressed it only changes the Equipped Value to true and when i press it again, it just prints out (“glock is chosen”) and neither Equipped or deequipped.

  3. What solutions have you tried so far? I have tried to look for the solutions on the devforum, they were either completely irrelevant or did not match my problem directly. I have tried to debug the code too with prints but as you can see that did not work kind of.

UIS.InputBegan:Connect(function(input, gpe)


	if input.KeyCode == Enum.KeyCode.E then
		print("glock is chosen")

		if  cooldown == false then
			cooldown = true

			if Equipped == false then --equip the gun
				print("equipped")
				Equipped = true
				GET_GUNEVENT:FireServer(Equipped)

			else--deequip the gun
				print("deequipped")
				Equipped = false 
				GET_GUNEVENT:FireServer(Equipped)

			end


			task.wait(cooldown_value)
			cooldown = true

		end


	end
end)

UIS.InputBegan:Connect(function(input, gpe)


	if input.KeyCode == Enum.KeyCode.E then
		print("glock is chosen")

		if  cooldown == false then
			cooldown = true

			if Equipped == false then --equip the gun
				print("equipped")
				Equipped = true
				GET_GUNEVENT:FireServer(Equipped)

			else--deequip the gun
				print("deequipped")
				Equipped = false 
				GET_GUNEVENT:FireServer(Equipped)

			end


			task.wait(cooldown_value)
-- I CHANGD THIS TO SET TO FALSE
			cooldown = false
		end


	end
end)

at the end of the click event you change the cooldown to tru instead of false

1 Like

Thank you so much. I can’t believe I didn’t see that, guess i’m just blind lol.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.