Cant reload gun when i click R (contextactionservice)

PS.first of all im not really good in scripting and im not good in english

hello guys i’m trying to make an animation play when i click R but i get this error
image
here is how its in the explorer
image
here is the script

local holding = false
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()

local tool = script.Parent

local configs = tool.Configs
local reserveammo = configs.ReserveAmmo.Value
local magsize = configs.MagSize.Value
local ammo = configs.Ammo.Value
local reloadtime = configs.ReloadTime.Value

local actionService = game:GetService("ContextActionService")

local idleAnim = char:WaitForChild("Humanoid"):LoadAnimation(script.Hold)
local shootAnim = char:WaitForChild("Humanoid"):LoadAnimation(script.Recoil)
local reload = char:WaitForChild("Humanoid"):LoadAnimation(script.Reload)
local shootEff = tool.Hole.shoot
local equipeff = tool.Hole["Equip sound"]
local reloadeff = tool.Hole["Reload Sound"]

tool.Equipped:Connect(function()
	local mouse = game.Players.LocalPlayer:GetMouse()
	mouse.Icon = "http://www.roblox.com/asset?id=117431027"

	game.ReplicatedStorage.ConnectM6D:FireServer(tool.BodyAttach)

	char.UpperTorso.ToolGrip.Part0 = char.UpperTorso
	char.UpperTorso.ToolGrip.Part1 = tool.BodyAttach


	idleAnim:Play()
	equipeff:Play()
	holding = true
end)

tool.Unequipped:Connect(function()
	local mouse = game.Players.LocalPlayer:GetMouse()
	mouse.Icon = "http://www.roblox.com/asset?id=5801470647"

	game.ReplicatedStorage.DisconnectM6D:FireServer()

	idleAnim:Stop()
	equipeff:Play()
	holding = false
end)



tool.Activated:Connect(function()
	local canshoot = true
	if canshoot == true then
		wait()
		ammo = ammo - 1
		canshoot = false
		shootAnim:Play()
		shootEff:Play()
		wait(1)
		canshoot = true
	end
		

end)

local function reload()
	local canreload = true
	local needed = magsize - ammo
	if holding == true and canreload == true then
		wait()
		canreload = false
		ammo = magsize
		reserveammo = reserveammo - needed
			reload:Play()
		reloadeff:Play()
		wait(reloadtime)
		canreload = true
		end
	if reserveammo < 0 then
		ammo = ammo + reserveammo
		reserveammo = 0
	end
		end
actionService:BindAction("Reload", reload, false, Enum.KeyCode.R)

how can i fix it ?

1 Like

What is line 73? Is that the reload function?

The issue is that you named the reload variable the same as the function you used. One overwrote the other, rename either the reload function or the reload variable and change all uses of it to the new name

2 Likes

oh yeah!, im sorry i was not looking the variables,thx

Anytime! If you have anymore issues don’t be afraid to make another post!

1 Like