Trying to get a script for controllers working to reload the gun in my game.
This is the working script that reloads when you press R on the keyboard
function Reload(key) key = key:lower() if key == 'r' then if enabled == true and Gun.Ammo.Value < MaxAmmo and script.Parent.CanReload.Value == true then LoadSound:Play() wait(LoadSound.TimeLength) Gun.Ammo.Value = MaxAmmo end end end
This is the broken script that doesn't work when you press X on the gamepad
function ReloadController(controller) game:GetService("UserInputService").InputBegan:connect(function(input) if input.UserInputType == Enum.UserInputType.Gamepad1 then if input.KeyCode == Enum.KeyCode.ButtonX then if enabled == true and Gun.Ammo.Value < MaxAmmo and script.Parent.CanReload.Value == true then LoadSound:Play() wait(LoadSound.TimeLength) Gun.Ammo.Value = MaxAmmo end end end end) end
On the second block of code, you didn't close the function(input on line 2.