Client doesn’t execute command, code only works on server

Updated on June 29, 2018 in [A] Multiplayer
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
0 on June 29, 2018

Hey there guys, I’ve got some code that just doesn’t want to work correctly. When the Server executes the code, everything is fine, and the clients respond to it as well, but when the client executes the code, nothing happens, on the server nor the client.

 

void Update () {
        if(Input.GetKeyDown(KeyCode.P) && hasBeenPlanted == false)
        {
            hasBeenPlanted = true;
        } 
        if(hasBeenPlanted == true && started == false)
        {
            
            started = true;
            if (isServer)
            {
                Debug.LogError("Server");
                RpcdoBombLogic();
                
            }
            else
            {
               CmddoBombLogic()
                Debug.LogError("Client");
                
            }
                
        }
 
 [Command]
    public void CmddoBombLogic()
    {
        BombMusic.Play();
        Debug.LogError("Testing");
        RpcdoBombLogic();
    }
    [ClientRpc]
    public void RpcdoBombLogic()
    {
        BombMusic.Play();
        Cmdtensemusic();
    }

 

So as you can see, I added some Debug.LogErrors to test, and when I activate the code, it show’s the Error with “Client”, on the client, but doesn’t show the logerror with “Testing”, (also not on the server) neither does it execute the “Bombmusic.Play();”.

Thanks in advance for helping me,

Tristan

  • Liked by
Reply