Hello! I seem to be having issues with 2 parts of my code.
Firstly when you click R it’s meant to reload but it seems to refuse to do that.
ActionService:BindAction("Reload", Reload, false, Enum.KeyCode.R) --//Reload with R\\--
Secondly I have another issue with telling the script when you are reloading.
local function Reload(plr)
--//Initialize\\--
if not CanReload() then return
--//Reload\\--
Reloading = true ---//This is the part of the script with an error.
ReloadSound:Play()
--//Handle Ammo\\--
local Needed = MagSize.Value - Ammo.Value
ReserveAmmo.Value = ReserveAmmo.Value - Needed
Ammo.Value = MagSize.Value
--//Ensure Reserved ammo does not go negative\\--
if ReserveAmmo.Value < 0 then
Ammo.Value = Ammo.Value + ReserveAmmo.Value --//Add the nevative with the Reserved\\--
Ammo.Value = 0 --//Resets Ammo\\--
end
end
end
Errors:
This is the error for the Reloading = true
Players.tyler09456.Backpack.DH-17.Scripts.BackendScript:69: Expected ‘end’ (to close ‘then’ at line 66), got ‘=’
This is the error for the R for reload.
Players.tyler09456.Backpack.DH-17.Scripts.FrontendScript:170: attempt to call a nil value