Moving instances around roblox studio services

The title is a little confusing lol

Im making this system where players can switch their ability movesets back and foward by pressing Q and E. By pressing these keys their moves will change. You could think of it as it cycles through a bunch of things so players wont be stuck with the last move on the list.

The problem im having is i cant figure out a way to move folders containing scripts back and foward out of the players backpack. Ive tried this before but the script keeps yielding so im not sure what im doing wrong.

Heres an example of what im trying to do

-OnServerEvent things blahblah blah 

if args == 1 then
   value.Value = false
   if value.Value == false then
       folder1.Parent = plr.Backpack
       folder2.Parent = game.ServerStorage.FolderStorage
       --Either that or destroy folder2
   end
end

if args == 2 then
   value.Value = true
   if value.Value == true then
       folder1.Parent = game.ServerStorage.FolderStorage
       folder2.Parent = plr.Backpack
       --Either that or destroy folder1
   end
end

Ive tried this system and as said before the code keeps yielding. Ive added wait for childs yet nothing works so i just deleteted that part of the code and want to start again.

Help and feedback is appriechiated. :slightly_smiling_face:

Thank you for your time

2 Likes

i would just clone folders instead of using the same folder scripts, they are probably trying to pick up a nonexistant player and yielding until the player is present

ex

folder1:Clone().Parent = plr.Backpack;
--destroy old folder here
1 Like

This kinda worked? i tried this out but theres an error

Determination is not a valid member of Backpack "Players.Pyromxnia.Backpack"

Heres the script

	local char = plr.Character
	local sword = char:FindFirstChild("Sword") 
	local shield = char:FindFirstChild("Shield")
	
	local value = char:FindFirstChild("Mode 2")
	local folder = plr.Backpack.Determination
	local BP = plr.Backpack
	
	local DMode1 = game.ServerStorage.Characters.Determination:Clone()
	local DMode2 = game.ServerStorage.Characters.Modes.DMode2:Clone()
	
	
	if args == 1 then
		print("Mode 1")
		
		local folder2 = BP.DMode2
		folder2:Destroy()
		
		DMode1.parent = BP
		for _, v in pairs(DMode1:GetDescendants()) do
			if v:IsA("Script") or v:IsA("LocalScript") then
				v.Disabled = false
			end
		end
		value.Value = false 
		local tween1 = TS:Create(sword, TweenInfo.new(.5), goal2)
		local tween2 = TS:Create(sword.Wings, TweenInfo.new(.5), goal2)
		local tween3 = TS:Create(sword.Wings.Blade, TweenInfo.new(.5), goal2)
		
		local tween4 = TS:Create(shield, TweenInfo.new(.5), goal2)
		local tween5 = TS:Create(shield.Union, TweenInfo.new(.5), {Transparency = 0.5})
		
		
		tween1:Play()
		tween2:Play()
		tween3:Play()
		
		tween4:Play()
		tween5:Play()
		
		sword.PointLight.Enabled = true
	elseif args == 2 then
		print("Mode 2")
		
		folder:Destroy()
		DMode2.Parent = BP
		for _, v in pairs(DMode2:GetDescendants()) do
			if v:IsA("Script") or v:IsA("LocalScript") then
				v.Disabled = false
			end
		end
		value.Value = true
		local tween1 = TS:Create(sword, TweenInfo.new(.5), goal)
		local tween2 = TS:Create(sword.Wings, TweenInfo.new(.5), goal)
		local tween3 = TS:Create(sword.Wings.Blade, TweenInfo.new(.5), goal)

		local tween4 = TS:Create(shield, TweenInfo.new(.5), goal)
		local tween5 = TS:Create(shield.Union, TweenInfo.new(.5), goal)
		
		tween1:Play()
		tween2:Play()
		tween3:Play()

		tween4:Play()
		tween5:Play()
		
		sword.PointLight.Enabled = false

	end

Heres the part thats erroring

local folder = plr.Backpack.Determination

Well that means there isn’t a child named “Determination” inside of the backpack of the relevant player instance.

1 Like