Is there a reliable way to make a client based game structure be more safe from hacking?

To explain it simply, I’m making a game where the main gimmick of the game is something only the local player takes part in, other players can do the same but will be on their own versions of it, essentially they’re “Encounters” where you have a 1v1 against an AI enemy, is there a way to do this in a way that is secure? My main concern with running this on a client is that people might be able to edit how the game works to find means of cheesing it.

Other parts of the game have multiplayer features, just this is a 1v1 thing.

2 Likes

Even if the ‘encounter’ is just for the local client, it doesn’t stop you from using the server to verify actions and data before proceeding. Everything that the client sees & has can be accessed by the server, and therefore, you shouldn’t use the client to exclusively verify anything that has a value of significance in regards to player progression, gameplay performance, or saved data.

If this encounter is hosted within a multiplayer space then of course, you’ll need to find a way to organise encounter data so that someone else’s encounter data doesn’t collide with another player’s encounter data.

Is there a ideal way to set up encounters to not overlap on a server script?

if I understood what you’re asking correctly, instead of making a server script be the encounter, make a server script be responsible for creating them. structuring your scripts that way should allow for them to make as many ongoing “sessions” as needed

-- bad:
-- add encounter logic here
-- impossible to have concurrent encounters other than duplicating this script

-- good:
function CreateEncounter(player)
	-- add encounter logic here, make it completely isolated to this function
end
-- connect an event to run CreateEncounter or something

if you meant something else please elaborate

1 Like

I’ve attempted something like this and it’s just extremely difficult to make work, especially with stuff like models that I want to only be visible and active on the client side that seemingly just gets broadcasted to every client instead of just one.

I presume a issue was started because I was firing ModuleScript functions from inside the server when the event got called off from one client?

1 Like

it has nothing to do with where the event is being called from, just that the server is the authority of the game and so anything it parents to workspace on it’s side will be replicated to everyone else.

try making a folder for each player that joins the server. those folders should have the player’s username and be stored in workspace. when the client joins / sees a folder get added, it checks if the folder’s name is the local player’s username and if not it destroys it. that should allow you to parent things to their corresponding folders on the server without other clients being able to see them.

also don’t forget to destroy those folders when the player leaves the game.