I NEED some form of a server-side mouse position (3D) property

I know, it’s ridiculous: "Server-side version of a client-side property? WHAT?! "

Unfortunately with the lack of a server-replicated property - even a mere Vector3 - of a client’s mouse location in 3D space, I have to resort to the worst possible method of getting that information:

local MousePos = Vector3.new()
while wait(0.1) do -- https://www.youtube.com/watch?v=WtJsHWdUHwE !!!
    MousePos = SomeRemoteFunctionToGetMouseHitP:InvokeClient(Client)
end

Note: I use a RemoteEvent fired from the client in my own code, should you continue reading the thread.

So, how could a server-version of the client’s mouse position possibly be beneficial?

  • No more network intensive code (like above code-snip)
  • An easy way to run things like guns/turrets (that have a client controlling them) from the server
  • The need for FE-Compliant (laggy, like above code-snip) code is gone for things like this.
  • I’m sure there’s more ideas that people could add.

Feedback?

Why do you need that value serverside?

2 Likes

The main reason I need it is because, similarly to one of my examples, I’m trying to make a car with mounted guns that a player can drive. With FE, I can’t use a LocalScript to drive the car and turn the guns - I have to do it on the server so that it replicates. This means that, as I said in my original post, I have to resort to repeatedly calling a RemoteFunction / RemoteEvent for the server to know where my client’s mouse is.

Here’s the project with the car: https://www.youtube.com/watch?v=_4D6nIcVTZI

This is not a very good idea in terms of user responsiveness though

You might want to visualise someone else’s pointer (i.e. in a drawing game, or something like table top simulator).

IMO does not need to be an engine feature though, especially because it can be solved with a little bit of Lua code. Networking would happen anyway, it would just be by the engine then instead of your code.

If you can make the argument for the mouse position replicating, you can make that argument for a lot of properties (and people most-likely will if this happens).

And that is not intensive at all.

You don’t need to request it from the client every time you need it. Just have the client constantly send the mouse position to the server and cache it.

Edit: Misread.

Is there a better way to send it as opposed to constantly firing a RemoteEvent?

1 Like

Sharksie means use a RemoteEvent and constantly fire that from the client, don’t use a RemoteFunction for it.

Ah. Okay. I’m doing that already in my ship code. The RemoteEvent is fired every 0.1 seconds, sending Mouse.Hit.p to the server.

Edit: Nevermind the post, I’ll optimize it myself given that it’s fairly short for a script.

You should store the direction relative to the car.
If the car turns left, the gun also turns left, but relative to the car, doesn’t move.
You only need to (re)send the direction if it changed (too much).

I gotcha fam.

1 Like

A mouse hit location is not the same for every game because some games want to filter transparent parts, others want to filter something else when casting a ray from viewport to world.

Derp.

Thanks, mate! --Demoman

This should satisfy the need for said not-intensive code.