# HasAuthority() returning true for Client

**URL:** <https://forums.unrealengine.com/t/hasauthority-returning-true-for-client/54394>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [February 3, 2016, 6:28pm UTC](https://forums.unrealengine.com/t/hasauthority-returning-true-for-client/54394 "2016-02-03T18:28:24Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Van\_Hinten](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Van\_Hinten](https://forums.unrealengine.com/u/Van_Hinten)\
**Post date:** [February 3, 2016, 6:28pm UTC](https://forums.unrealengine.com/t/hasauthority-returning-true-for-client/54394/1 "2016-02-03T18:28:24Z")

</div>

Hi,

I am starting to add multiplayer to my prototype and wanted to try a little around so I fired up a new C++ ThirdPersonTemplate and just wanted to mess around a little. The first thing I tried was printing a text if I am playing on the Server so I added the Tick() function to the C++ character and this 2 lines of code

```auto

if(HasAuthority())
		GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Test"));

```

I didnt change anything else but the message is printed on both Client and Server and I can’t figure out why.

**EDIT**  
Ok am I missing something here. If I add those line in any other function then the Tick() function it’s working. But why?

---

<div class="post-metadata">

**Author:** ![Vindomire](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Vindomire](https://forums.unrealengine.com/u/Vindomire)\
**Post date:** [February 4, 2016, 7:18pm UTC](https://forums.unrealengine.com/t/hasauthority-returning-true-for-client/54394/2 "2016-02-04T19:18:40Z")

</div>

I’ve found authority is a bit ambiguous. The client can seemingly have authority over some things and the server others… PERHAPS the tick function give the client authority? Just a guess…

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_683d4c63](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_683d4c63](https://forums.unrealengine.com/u/anonymous_user_683d4c63)\
**Post date:** [February 4, 2016, 8:49pm UTC](https://forums.unrealengine.com/t/hasauthority-returning-true-for-client/54394/3 "2016-02-04T20:49:50Z")

</div>

You should watch this tutorial series: [- YouTube](https://www.youtube.com/watch?v=TbaOyvWfJE0&list=PLZlv_N0_O1gYwhBTjNLSFPRiBpwe5sTwc&index=1)

It is really great and explains all the things you need to start understanding networking in Unreal Engine.

---

<div class="post-metadata">

**Author:** ![Jambax](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jambax/32/904177_2.png) [@Jambax](https://forums.unrealengine.com/u/Jambax)\
**Post date:** [February 4, 2016, 10:42pm UTC](https://forums.unrealengine.com/t/hasauthority-returning-true-for-client/54394/4 "2016-02-04T22:42:33Z")

</div>

The Client will have Authority for that actor if it spawned the object.

---

<div class="post-metadata">

**Author:** ![Paulo\_Egidio](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Paulo\_Egidio](https://forums.unrealengine.com/u/Paulo_Egidio)\
**Post date:** [December 11, 2020, 9:39pm UTC](https://forums.unrealengine.com/t/hasauthority-returning-true-for-client/54394/5 "2020-12-11T21:39:04Z")

</div>

> [@Jambax](#):
>
> The Client will have Authority for that actor if it spawned the object.

But if that only servers could spawn replicated actors, maybe you mean:  
1 - the client call some rpc on server that spawns the actor  
2 then some code inside the engine understands this and puts this client having authority over the actor?

Is that correct?  
Thanks in advance  
Paulo

---

<div class="post-metadata">

**Author:** ![Jambax](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jambax/32/904177_2.png) [@Jambax](https://forums.unrealengine.com/u/Jambax)\
**Post date:** [December 12, 2020, 9:37am UTC](https://forums.unrealengine.com/t/hasauthority-returning-true-for-client/54394/7 "2020-12-12T09:37:52Z")

</div>

> [@Paulo\_Egidio](#):
>
> But if that only servers could spawn replicated actors, maybe you mean:  
> 1 - the client call some rpc on server that spawns the actor  
> 2 then some code inside the engine understands this and puts this client having authority over the actor?
> 
> Is that correct?  
> Thanks in advance  
> Paulo

Clients can still spawn actors - but if they do, the actor will only exist locally and the Client will therefore have authority over it. They won’t be able to call RPC’s, since the actor only exists on their machine. There are many cases where a Client can have Authority over something, another example is if you “Tear Off” a replicated actor, Clients will then have Authority over their local instance of that actor once the torn off state replicates.

HasAuthority() simply means “I can do what I want with this actor” - it doesn’t neccesarily mean that actor is Server-Authoritative.

---

<div class="post-metadata">

**Author:** ![xMotherSplicedx](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@xMotherSplicedx](https://forums.unrealengine.com/u/xMotherSplicedx)\
**Post date:** [February 11, 2022, 8:24pm UTC](https://forums.unrealengine.com/t/hasauthority-returning-true-for-client/54394/8 "2022-02-11T20:24:18Z")

</div>

I had a similar issue and noticed I had my Editor set to Net Mode: Play As Standalone. Change this to Play As Listen Server and see if that fixes your issue.

I believe when you use Standalone all of the clients are simulated on the server which makes HasAuthority() always return true.

---

<div class="post-metadata">

**Author:** ![Jambax](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jambax/32/904177_2.png) [@Jambax](https://forums.unrealengine.com/u/Jambax)\
**Post date:** [October 11, 2022, 8:13am UTC](https://forums.unrealengine.com/t/hasauthority-returning-true-for-client/54394/9 "2022-10-11T08:13:24Z")

</div>

If you play in Standalone then there is no networked game - it’s like being a Server without any networking layer. Obviously in Standalone, everything is running on your local machine so HasAuthority() would always be true.

---

<div class="post-metadata">

**Author:** ![nande](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nande/32/1057698_2.png) [@nande](https://forums.unrealengine.com/u/nande)\
**Post date:** [April 15, 2024, 1:39am UTC](https://forums.unrealengine.com/t/hasauthority-returning-true-for-client/54394/10 "2024-04-15T01:39:12Z")

</div>

is there a way to check whether a piece of code is running on the server or the client regardless of who owns it?

---

<div class="post-metadata">

**Author:** ![Auran131](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Auran131](https://forums.unrealengine.com/u/Auran131)\
**Post date:** [April 15, 2024, 3:33am UTC](https://forums.unrealengine.com/t/hasauthority-returning-true-for-client/54394/11 "2024-04-15T03:33:33Z")

</div>

just use a print string, it’ll say server or client

---

<div class="post-metadata">

**Author:** ![nande](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nande/32/1057698_2.png) [@nande](https://forums.unrealengine.com/u/nande)\
**Post date:** [April 15, 2024, 10:36pm UTC](https://forums.unrealengine.com/t/hasauthority-returning-true-for-client/54394/12 "2024-04-15T22:36:47Z")

</div>

thanks, but i think you missunderstood my question.  
what i meant is how to detect if it’s the server, not if it has authority.

after doing my own research i found that the closest thing is using !IsNetMode(NM\_Client) (or using nm\_server and nm\_standalone).

---

<div class="post-metadata">

**Author:** ![Auran131](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Auran131](https://forums.unrealengine.com/u/Auran131)\
**Post date:** [April 16, 2024, 12:04am UTC](https://forums.unrealengine.com/t/hasauthority-returning-true-for-client/54394/13 "2024-04-16T00:04:52Z")

</div>

the is an IsServer() function too?

---

<div class="post-metadata">

**Author:** ![nande](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nande/32/1057698_2.png) [@nande](https://forums.unrealengine.com/u/nande)\
**Post date:** [April 16, 2024, 10:39pm UTC](https://forums.unrealengine.com/t/hasauthority-returning-true-for-client/54394/14 "2024-04-16T22:39:01Z")

</div>

on cpp it’s deprecated, but it doesn’t say why.  
i’ve remember having read a warning at some point in favor of IsNetMode instead of IsServer or somthing similar.  
“Server” is usually ambiguous, with standalone, dedicated, and listen. but im not sure what it means on that function.  
on cpp at least seems to rely on the net driver (iirc), and im not sure about the implications.

---

<div class="post-metadata">

**Author:** ![Auran131](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Auran131](https://forums.unrealengine.com/u/Auran131)\
**Post date:** [April 16, 2024, 11:34pm UTC](https://forums.unrealengine.com/t/hasauthority-returning-true-for-client/54394/15 "2024-04-16T23:34:14Z")

</div>

you could go into the c++ of IsServer and see how they do it? either way it still works for now.

or what are you trying to achieve?

---

<div class="post-metadata">

**Author:** ![nande](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nande/32/1057698_2.png) [@nande](https://forums.unrealengine.com/u/nande)\
**Post date:** [April 17, 2024, 12:10am UTC](https://forums.unrealengine.com/t/hasauthority-returning-true-for-client/54394/16 "2024-04-17T00:10:54Z")

</div>

thanks, i already done that. that’s how i have that info.  
what am i trying to achieve? like i said. detect when it’s server not only when it has auth.  
but anyway i’ve already solved it with the answer i posted above.
