How do i disable input key in other screen

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By mdswamp

hi, i use RPC method to send animation to other player screen, the problem is that when i press a key in player1 screen which belongs to player1, it works properly. but when i press the same key in player2 screen, it works again. what should i do to fix this problem?

func _input(event):
     if event.is_action_pressed("shoot"):
        right_shoot()
        rpc("right_shoot")

slave func right_shoot():
    do_something

and this is the codes belong to stage (player 1 and 2 instance to stage node)

func _ready():
	if (get_tree().is_network_server()):
		player2.set_network_master(get_tree().get_network_connected_peers()[0])
	else:
		player2.set_network_master(get_tree().get_network_unique_id())

(it is one on one game)

:bust_in_silhouette: Reply From: mdswamp

ok i created a boolean variable in singleton and added it to host and join function.
its true, when player is client and its false, when player is server and then used this variable in the above condition, it fixed my problem:

if global.client == true && event.is_action_pressed(“shoot”):
((for client))
if global.client ==false && event.is_action_pressed(“shoot”):
((for server))

:slight_smile: