attempt to index local 'arguments' (a number value)


			if (string.find(arguments[1], 0) or string.find(arguments[1], 1)) then
				if (arguments == 0) then
					scanner:KeyValue("SpotlightDisabled", arguments);
					Clockwork.player:Notify(player, "You disabled your spotlight!");
				end;

Errors
attempt to index local ‘arguments’ (a number value)

Paste the whole function. arguments is a number in that context, thus string functions won’t work


local COMMAND = Clockwork.command:New("ScannerSpotlight");
COMMAND.tip = "Enable the spotlight (as a scanner).";
COMMAND.text = "<number Value>";
COMMAND.arguments = 1;

-- Called when the command has been run.
function COMMAND:OnRun(player, arguments)
	if (Schema.scanners[player]) then
		local scanner = Schema.scanners[player][1];
		
		if (IsValid(scanner)) then
			local arguments = tonumber(arguments[1])
			
			if (string.find(arguments[1], 0) or string.find(arguments[1], 1)) then
				if (arguments == 0) then
					scanner:KeyValue("SpotlightDisabled", arguments);
					Clockwork.player:Notify(player, "You disabled your spotlight!");
				end;

				elseif (arguments == 1) then
					scanner:KeyValue("SpotlightDisabled", arguments);
					Clockwork.player:Notify(player, "You enabled your spotlight!");
			else
				Clockwork.player:Notify(player, "You can only choose 0 or 1!");
			end;
		end;
	else
		Clockwork.player:Notify(player, "You are not a scanner!");
	end;
end;

COMMAND:Register();

The string.find check is useless.


if (IsValid(scanner)) then
	local arguments = tonumber(arguments[1])
	
	if (arguments == 0) then
		scanner:KeyValue("SpotlightDisabled", arguments);
		Clockwork.player:Notify(player, "You disabled your spotlight!");
	elseif (arguments == 1) then
		scanner:KeyValue("SpotlightDisabled", arguments);
		Clockwork.player:Notify(player, "You enabled your spotlight!");
	else
		Clockwork.player:Notify(player, "You can only choose 0 or 1!");
	end;
end;

there is another one saying ‘TEXT’

inside sv_hooks


-- Called when a player switches their flashlight on or off.
function Schema:PlayerSwitchFlashlight(player, on)
	if (on and (player:GetSharedVar("tied") != 0)) then
		return false;
	end;
	
	if (on and (self.scanners[player])) then
		Clockwork.player:RunClockworkCommand(player, "ScannerSpotlight", 1);
	elseif off then
		Clockwork.player:RunClockworkCommand(player, "ScannerSpotlight", 0);
	end;
end;

problem number 3

SpotlightDisabled is a keyvalue when I used KeyValue it said that it didn’t know what that is, when I used SetKeyValue I think it created one cause nothing happend.

There is an input called “DisableSpotlight” but I am not sure what it does.
Does it also have 0 or 1?

What I tried at sv_hooks is that instead of having access to flashlight that it can change his scannerspotlight.
It still does have access to it.


elseif off then

off isn’t defined. Did you mean “not on”?

SetKeyValue accepts a string only, so doing the tonumber conversion might cause it to not work. Also, from the description, DisableSpotlight only spawns the scanner without the spotlight enabled, but doesn’t completely disable it. You might want to try setting the length and width of the spotlight to 0.

SpotlightLength does this go through walls I don’t guess so?
Is there a default length?

SpotlightWidth same for this.

I am not doing a command for this. If its on 1 its enabled and then it needs a spotlightwidth and length

I removed the hook but making a spotlightlength and spotlightwidth didn’t help.

There is something where scanners enable its spotlight. SpotlightDisabled 0 turns the spotlight NORMALY on well its wrong spotlightdisabled means it will stay disabled for the scanner.

There is DisableSpotlight and this needs to have something and I am using the map editor to find this out.

Do you know a solution to this?