How would I go about making (dynamically draggable/moves as the mouse moves) GUIs “snap to grid”? I’ve thought of rounding the UDim2 down upon mouse release, although, that leaves the vulnerability of “unsnapped” positional data being saved to Datastores if the server shut down/player left without letting go of their mouse (i.e. AltF4-ing/running out of battery).
This could not only be a visual bug, but also allow the player to hold an extra item in their inventory. (Yes, I know I’m being a bit pedantic.)
Are there any better ways, or ways that could solve this issue; is this the best option?
If you’re handling the gui locally which I assume you are for the mouse position then just don’t replicate the changes until the person releases their mouse that way when the data is saved it won’t see the unsnapped position
Actually the only problem is if it clips with another item which could make two items in one spot or some other issue so make sure you check for that before just saving the rounded position
Actually it would be impossible to make it fully anti-exploitable, since local changes to GUI replicate across to the server. Unless I have a server-sided script that manages/validates these movements, which requires many remoteevents, and puts noticeable strain on the server. Hmm…
what will the player exploit? the amount of items or the type? because you don’t need to know those to change the item’s position in the inventory all you need to do is find the item’s current location then change it to the new one
If an exploiter changed the locations of the items in their inventory, then some grid sectors could be left unused, and others cramped between these grid slots (by directly changing the Position property. This means that the player can technically hold infinite items in their inventory.
The only way, I believe, to avoid this from happening is to let these GUIs be purely aesthetics (since after all, they are controlled by the client) and check for the amount of GUIs in the inventory from the server (upon ChildAdded).