So I’m trying to get a script to take a “Lobbies” folder in ServerStorage and update another “Lobbies” folder in ReplicatedStorage to have the same contents. However, when I simply set the ReplicatedStorage folder to be equal to the ServerStorage folder, it doesn’t update any of the contents. Is it only making the folder itself the same, ignoring the descendants?
Here’s my code:
while wait(1) do
if ReplicatedStorage:FindFirstChild("Lobbies") == nil then
local clonedLobbies = ServerStorage.Lobbies:Clone()
clonedLobbies.Parent = ReplicatedStorage
else
local repStorageLobbies = game.ReplicatedStorage:WaitForChild("Lobbies")
repStorageLobbies = ServerStorage.Lobbies
end
print("Updated")
end
It checks if the “Lobbies” folder exists already inside of ReplicatedStorage, and if it does not, it’ll clone the folder from ServerStorage, and parent it to ReplicatedStorage. If it does exist, then simply set repStorageLobbies to be ServerStorage.Lobbies. Cloning works just fine, but once it already exists the section of code after else does not work as intended. So, when I change anything inside of the ServerStorage “Lobbies” folder, the changes do not appear on the ReplicatedStorage folder that should be updating.
As a side note, the reason I don’t want to re-clone the folder every second is because I’m using this folder in ReplicatedStorage to keep different parts of my game updated (GUI mainly).
Any idea on how to update the contents of the folder? Thanks.
You want to replace the folder in Replicated Storage right? So you could destroy the current folder and replace it with the one from Replicated Storage. Also why are you updating it every second. Is it because other scripts take from the Lobbies folder?
while wait(1) do
if ReplicatedStorage:FindFirstChild("Lobbies") == nil then
local clonedLobbies = ServerStorage.Lobbies:Clone()
clonedLobbies.Parent = ReplicatedStorage
else
ReplicatedStorage:FindFirstChild("Lobbies"):Destroy()
local clonedLobbies = ServerStorage.Lobbies:Clone()
clonedLobbies.Parent = ReplicatedStorage
end
print("Updated")
end
Well what I’m trying to do is have a lobby system where players can join each other’s lobbies and queue for a match. However, I want to make sure that exploiters cannot disrupt these lobbies, since that’d end badly. Thus, my idea was to have a main “Lobbies” folder in ServerStorage, and only update a folder in ReplicatedStorage every second to be exactly the same. This way, there’d be less problems with expoiters and would allow client-side access to the lobbies folder (to update the GUI from LocalScripts).
I could use a singular “Lobbies” folder in ReplicatedStorage, but I simply want to make sure that exploiters cannot negatively impact these lobbies. Any idea on if it’s actually safe to place it all there?
And ah okay, that makes sense; I just noticed that.
About your question, you can read what I said in this reply above (it should clarify what I’m trying to do).
In the main topic, I mentioned the above, saying that I can’t re-clone the folder every second while keeping things easy to manage. For example, if an admin was trying to go into the folder to fix something, it would keep deleting and cloning back, not allowing them to do anything.
That’s what I’m wondering as well; so, here I am either trying to get input on what they can do, or help on how to keep things server-side as much as possible by keeping the main folder in ServerStorage. From what I’ve been reading, it seems that exploiters can access ReplicatedStorage, but changes they make are only local to them. That would explain why they can mess with RemoteEvents but not other objects placed in ReplicatedStorage, but I’m not completely sure.
Do you believe that placing the folder in ReplicatedStorage alone will be alright? I just want to make sure that it is not vulnerable to unwanted manipulation. Thanks.
Local changes are are only local, as you mentioned. Unless you have a remote which tells the server to change something in ReplicatedStorage, the client won’t be able to globally change it.
It should be enough to store objects in RS and still avoid tampering.