How do I replicate stuff to only some clients?

Hi! :D
If I were making a game where you collect things for currency and buy new areas to collect more things, how can I make those collectibles not show up to players that haven’t bought the zone, meaning how can I have the items replicate only if / when a player bought the zone?
I want to do that for security reasons to avoid the game being exploited by no-clipping through the barriers.
I don’t know how to do it, but I am sure that this is possible because Weapon Simulator has that feature. The characters to defeat don’t show up until you buy their zone.

Thanks in advance,
Mun :smile:

2 Likes

You can spawn the collectables on the server. To make it so you can only pick up collectibles in an area you own then you add an if statement that checks weather the player owns the area.

So something along these lines:

--//Inside the collectable pickup code
if player.OwnedAreas.[area].Value == true then
    PickupCollectable()
end

This could even work on the characters too.

2 Likes

Place the things in ReplicatedStorage and then clone them into the workspace with a local script.

Oops I replied to the wrong person.

2 Likes

You could do multiple things to combat this. One of them is to still display the items to all clients, but whenever a client picks them up, do a server check to see if the client can actually pick the item up.

Another method would be to make a replication system where you tell each client individually what they are and are not able to see. I prefer this method since in this scenario only the client would render the physical object. Just store position data or something similar so that you can verify whenever the client sends a request to the server asking to pick up the item.

5 Likes

Easiest way would of course be to have a local script control which player sees which items, but if you are able to do so, @AlreadyPro’s solution is more secure.

1 Like

Place a part on the server where you want each item to be > Render each item on the client and position them at the part located on the server > When the player touches the part on the server check if they have that area unlocked > If that have that area unlocked then grant them the item, remove the part on the server and tell the client to remove the item from workspace. This could be good because whenever a new “Part” is added to the server to represent a collection object you could then Fire all the clients that have that area unlocked. You would also want to fire the client with the same data when a player unlocks a new area just so it updates the models. Many ways to do this but this is a more simple way, some people use more advanced LOD(level of detail) systems which have more advanced loading and unloading. You could look something up relating to those if you wish.

2 Likes

I dont say i am pro, but it is
if player.OwnedAreas[area].Value == true then PickupCollectable() end
so without dot before [area]

2 Likes

You can do this but with large amounts of parts this is not a good idea. Everything in replicated storage is replicated to the client constantly. so with constantly changing files (such as ragdolls in a big game) it will take away from bandwidth you could have used elsewhere.

2 Likes

[Area] as in the objectname…

1 Like

Ok, i through i an importing the object name from string

1 Like

Thanks everyone for the replies! These are some great solutions. I will definately try them out!
Unfortunately, my game mechanics to collect the items isn’t as simple as touching it, it’s more complicated, so some of them wouldn’t work, but I’ll definately find a way to secure it anyways.

P.S

^ That is right.

Thanks again to everyone! :D

2 Likes

It’s as easy as checking on the client to see if they own the zone, and if they don’t then make the items invisible.

Like mistr88 said, also perform checks on the server to see if the player is actually able to interact but otherwise there is no fancy replication hacks that need to happen. It’s honestly as simple as Item.Transparency = 1 on any client that isn’t supposed to see them.

1 Like