I used the command
/c game.player.character = nil
on the console, then clicked your button and got this crash:
The mod Kagebunshin_mode (2.2.2) caused a non-recoverable error.
Please report this error to the mod author.
Error while running event Kagebunshin_mode::on_gui_click (ID 1)
__Kagebunshin_mode__/clones.lua:31: attempt to index field 'character' (a nil value)
stack traceback:
__Kagebunshin_mode__/clones.lua:31: in function 'create_new_character_behind_player'
__Kagebunshin_mode__/clones.lua:49: in function 'create_character'
__Kagebunshin_mode__/button.lua:26: in function 'onHelloButtonClick'
__Kagebunshin_mode__/button.lua:41: in function <__Kagebunshin_mode__/button.lua:39>
You can fix this by getting the surface from player instead of player.character in create_new_character_behind_player():
-- surface = player.character.surface
surface = player.surface
I removed my character deliberately to break your mod. :-D However, players having no character is a real issue as there are mods that put players in god mode (e.g. the satellite navigation view of Space Exploration), so you definitely should fix this!