Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Items cannot be put away when cloned back?

Help! When the play clicks x for the second time and the items are brought in they cannot be deselected when selected causing them all to stack onto each other.

wait(1)
print("Loaded")
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local character = Player.Character
local Tools = Player.Backpack
local startgear = Player.StarterGear


function makegearstart()
	for i,v in pairs(Tools:GetChildren()) do 
        v:clone().Parent = startgear
    end
end
makegearstart()

-------------------------------------------
function speed(speed)
    character.Humanoid.WalkSpeed = speed -- speed function
end


function holdingtool()
	for _, child in pairs(character:GetChildren()) do
    if child.ClassName == "Tool" then
	 child:remove()
    end
end 
end

function givebacktool()
	for i,v in pairs(startgear:GetChildren()) do 
        v:clone().Parent = Tools
    end
end




Mouse.KeyDown:connect(function(Key) -- main thing
if Key == "x" then 
    if character.Humanoid.WalkSpeed > 0 then
        speed(0)
		Tools:Remove()
		holdingtool()
    else
        speed(16)
		givebacktool()
    end

end
end)

Do you know how to fix this? Thanks.

3 comments

0

Give a description of your script too so that we know what your trying to do

1

On line 44 --Tools:ClearAllChildren() --You have defined a path to the Backpack, which to my knowledge can't be removed so easily. This will remove everything in it.

1 answer

Edit: He completely changed the question...

ServerStorage can only be accessed with server scripts.

You should use ReplicatedStorage instead as this can be accessed by clients and the server.

The reason this works in Studio is because there isn't a server, therefore the ServerStorage is located on the client instead.

For example instead of:

local Animation = game.ServerStorage.Animation

You should use:

local Animation = game:GetService("ReplicatedStorage").Animation

Also make sure you move the animation into the ReplicatedStorage

This discussion is preserved as it was. New answers, comments, and votes are closed.