Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Can the server get player GUI information without the client returning info?

Asked by 4 years ago

So I have a 2D game made with GUIs. Multiplayer is also involved too, I made a replication system which in theory should make the server obtain positions about "gui ships" to send to other players for them to "draw" them.

The problem is, everytime I test it the server returns the same position which is where the ship started in the StarterPack. I'm not sure if the server can obtain information about GUIs in players but that's how my replication system runs on.

My system works like this:

  • The clients fire the server with RemoteFunction:InvokeServer()

  • The server loops the players and puts their positions in a table

  • The server then fires :FireAllClients() and returns the table

  • The clients receive the table and "draw" ships onto the map

The process runs on a Renderstepped event firing each time.

I'm just asking if the server can get gui information about players. if not you can provide some alternatives to my replicating system. Thanks for reading

0
You can see PlayerGui in the Player, but you can't actually access anything inside it on the server. You'll need remotes. MrLonely1221 701 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

You can have Roblox replicate user input to the server by having the server clone guis into a player's PlayerGui (not using StarterGui), but this will suffer from input lag (ex if the player clicks a button and the code to handle it is on the server, the button will take a moment to respond).

Instead, it's preferable to use a RemoteEvent or RemoteFunction to allow the clients to request a change to their ship. The most secure method is that the client sends a number representing something the player wants to do, like "player requests to turn left", or "player wants to speed up". Thus, the server knows where the player's ship is at all times. If you want a more responsive input method, you could either investigate client-side-prediction (it's an advanced technique) or do what Roblox does: trust the client and let the client tell the server "my ship is at these coordinates". Optionally you can try to make sure that the ship isn't teleporting around the map or going at speeds faster than it should - but be careful if you do this, as it's easy to accidentally identify a legitimate player as an exploiter.

So, the general idea is that the GUI is only output; the server will track where everyone's ship is using a table - it won't need to touch any GUI to know where the ships are.

0
Thanks for the information I try the new method and see if it works. 123nabilben123 499 — 4y
Ad

Answer this question