So I am attempting to make a custom backpack system. I have it so that anything parented to the normal backpack gets reparented to another folder parented to the player named “CustomBackpack”. This system works well and lets me manage what actually gets to go where in the backpack. The issue is that once a server script is parented in here it will cease to function. This applies even if it has been disabled first. Once parented any running scripts will cease to run and if they have been disabled first and then reenabled when equipped by the player they will not run either. Does anyone have any ideas on how I might be able to get around this issue?
So anything put in your original backpack will get re-parented to the a folder in the player named custom backpack? and the server script in the tool under custom backpack is not working?
Yes, if I leave the script enabled it runs for about a frame before stopping as it is moved to the custom backpack. I have a while loop that runs and just prints in order to test when it is active. It is only active for that first frame when moved from the backpack. Even if I move it to the workspace it will not continue to run.
I don’t suggest putting server scripts in the player/character due to the fact that the client can exploit them. I believe local scripts will run if you did that though.
The local scripts do run, but only once they reach the workspace. The code in the server script is not dangerous, its effectively just a passthrough for remotes. Im using tool instances so its not like what Im doing is uncommon to have server scripts in them.
Sorry help me understand a little better(For testing). When you equip the tool is it being equipped locally or through a remote event? Also you are putting remote events and the script under the tool too?
The tool is just being equipped through roblox’s :EquipTool() function. I have attached an image of the hierarchy after it has been moved so you can get a better idea of where its going.
Okay I think I figured it out! Did you create the Custom Backpack through a local script?
No, that is handled server side. The server sets up the folder and then reads when an item is inserted into the normal backpack from something like starterpack and it is then moved to the appropriate customBackpack spot and assigned various attributes for handling stuff like stackable items.
Are you equipping it through the client?
No, the server handles all logic. The tools get put in and are usable like normal, the only issue is that server scripts for some reason get messed up in the process of parenting.
As in they just stop working right?
Yes, they just wont run at all once moved
I think it’s not working because you are using EquipTool(). Not sure why this happens but if you do Tool.Parent = Player.Character then it should fix the issue.
Albeit I need to prove this, I think that’s because it normally does not run there, there are places where a normal script can run but localscript cannot run, or the opposite.
(edit: attempting to make a repro at the moment)
Just directly parenting it seems to fix things. Thats super odd that roblox’s method breaks things like that. I just assumed it was a more secure parenting for tools. Thanks