ContextActionService:BindAction("Reload", Gun:Reload, false, Enum.KeyCode.R)
Also, if you want to make a reload script try this script (found it on the DevHub):
local ContextActionService = game:GetService("ContextActionService")
local ACTION_RELOAD = "Reload"
local tool = script.Parent
local function handleAction(actionName, inputState, inputObject)
if actionName == ACTION_RELOAD and inputState == Enum.UserInputState.Begin then
ContextActionService:BindAction(ACTION_RELOAD, handleAction, true, Enum.KeyCode.R)
I am sorry I should’ve been more clear the issue isn’t with context action service as it is working perfectly fine as whenever I press R the error appears but instead with how you get self as it is marking self as nil and I am unaware of a scenario on where you get self and bring it through the function.
^^ Gun.Reload is not defined in the first line here. Maybe it’s trying to do nil() and nil is not a function so it says “attempt to call a nil value” Try doing like print(self) print(self.Reload) before the ContextActionService error line.