Problem with getting items form a folder

Hi,
I encounter a problem when I try to loop over a folder which have some elements cloned when the game starts. I clone the elements from ReplicatedStorage in that folder. The thing is that when I press a button I am looping over that folder, but the loop is not finding the objects. Note that the object are in the folder before I am pressing that button. If I add a RemoteEvent in the script that I am looping from and connect it to the local script of the object, everything works fine. The thing is that I want to change attribute to that object, but nothing happen to it. I cannot change attribute even with RemoteEvent, because in the server script I need to have event.OnServerEvent:Connect(function) and in the local script event:FireServer() and the attribute is not changing because I am not making any action from the LocalScript to trigger the event. I don’t want to use RemoteFunction, because they are unsafe and I don’t want to use any RemoteFunction Modules to make it safe. Any suggestions?

4 Likes

Can you provide the code you are using?

1 Like

The code is just a for loop. Everything its ok with the loop. If I try to change the attribute of the object directly without using a for loop, its the same problem. If I print the object name it is printing its name, but the attribute not changing. I encounter the same problem in the past and I think its strange how roblox works. In the folder I loop I also have UIList and a localscript and if I print out the name of elements from the loop, its only printing those two elements, but not the frame objects that are inside also.

Are you using a client-side LocalScript to add those items to the folder or a server-side Script?

1 Like

They are cloned from Server Side.

Would you mind sending the code you are using, as well as a screenshot of the hierarchy/Explorer after the items have been cloned in?

It’s quite hard to help otherwise.

I try to change the attribute directly, but nothing happen. I guess it is because the item is cloned from other location and it cannot change its properties because its not detecting it in that folder even if it is. Roblox is strange sometimes. As I said before its just a simple for loop nothing special and its working as it should, only Roblox acting weird.

I encountered the same problem in the past with the same thing where I cloned some inventory frames.
Please tell me why isn’t working even when I directly access it? If I print it out, it prints the name but if I want to change something to it, nothing happen.

If I place a Remote Event inside the object’s LocalScript RemoteEvent.OnClientEvent:Connect(function(...) script.Parent.Visible = false or any other things end) and in Server Script RemoteEvent:FireClient(player) then I can do any modification on the properties, but I need to change its attribute and I cannot do it from LocalScript.

Just create new script (NOT LOCAL) In ServerScriptService, type this code, but change OnClientEvent to OnServerEvent

function loop(player)
local folder = player:WaitForChild(“PlayerGui”):WaitForChild(“Folder”)
for _, a in pairs(folder:GetChildren()) do
a:SetAttribute(“Attr”, “”)
end
end
loop()
And nothing happen!

I tried and the attribute is not changing if I reverse it!

You want to clone tool from folder in Rep. Storage to player’s inventory, or something other?

The items are cloned at the starts of the game from ProfileService. The items are also visible in a Inventory.

So, what you’re want to do?
.
.

.

The problem is that I cannot modify anything to them even if they are in the folder and also visible on screen.

Just move them from folder (in rblx studio) to workspace, change them, and return them back to that folder. Or Idk

For example when I press a button I want to change the selected object’s attribute, but nothing happen. The object is related to the button. If I print its name by pressing the same button, it prints the name, but if I want to change the visibility or other things, nothing happen :slight_smile:

I find this behavior very strange!

Hmm, I think I can’t help you, bcuz I never do it, and I don’t use tools in my games