Need help with taser script

I believe I’m doing something close to right lol. I cannot figure this out. I just need input on how to recognize Xbox button being pressed it fires but won’t reload. I have searched all over and can’t find anything close to what I’m looking for. Thank You

function onKeyDown(key)
	if key == Enum.KeyCode.DPadUp and Tool.Lamp.Light.Enabled == true then
		Tool.Lamp.Light.Enabled = false
	elseif key == Enum.KeyCode.DPadUp then
		Tool.Lamp.Light.Enabled = true
	end
	if key == Enum.KeyCode.ButtonX  and not enabled then
		safety = true
	elseif key == Enum.KeyCode.ButtonX  and cart then
		cart = false
		Tool.Cartr.Value = false
		Tool.Cart.Transparency = 1
		Tool.Cart.CanCollide = false
		Tool.CartPart1.Transparency = 1
		Tool.CartPart1.CanCollide = false
		Tool.CartPart2.Transparency = 1
		Tool.CartPart2.CanCollide = false
		Tool.BlastDoor1.Transparency = 1
		Tool.BlastDoor1.CanCollide = false
		Tool.BlastDoor2.Transparency = 1
		Tool.BlastDoor2.CanCollide = false
		if Tool.LineV.Value == true then
		target:FindFirstChild("strings"):remove()
		Tool.LineV.Value = false
			end
	elseif key == Enum.KeyCode.ButtonX then
		Tool.Cartr.Value = true
		Tool.Deployed.Value = false
		cart = true
		benabled = true
		target = nil
		Tool.Cart.Transparency = 0
		Tool.Cart.CanCollide = true
		Tool.CartPart1.Transparency = 0
		Tool.CartPart1.CanCollide = true
		Tool.CartPart2.Transparency = 0
		Tool.CartPart2.CanCollide = true
		Tool.BlastDoor1.Transparency = 0
		Tool.BlastDoor1.CanCollide = true
		Tool.BlastDoor2.Transparency = 0
		Tool.BlastDoor2.CanCollide = true
		if Tool.LineV.Value == true then
		target:FindFirstChild("strings"):remove()
		Tool.LineV.Value = false
			end
	end
end
1 Like

I guess what I’m asking is how do I define it to work for controllers.

1 Like