Does not stop the resource - StopResource issue

Hi!

I’ll start by showing you the code:

AddEventHandler('onResourceStart', function(resourceName)
	if(GetCurrentResourceName() ~= resourceName) then
		return
	elseif GetCurrentResourceName() ~= "myscript_name" then
		print( "Please rename the script" )
		StopResource( GetCurrentResourceName() )
	end

	while true do
		print("run")
		Wait(1000)
	end

end)

The problem is that if the script name is not the specified “myscript_name” nothing happens and the resource does not stop. What could be the problem?