Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Script Cloning scripts aren't working anymore? (I tried to be specific.)

Asked by
BiIinear 104
4 years ago

Sorry for the weird title. So I'm developing a script that clones another script, and places it into the designated descendants. I'm doing this because I can just edit one script instead of going to all of the tools localscripts and editing each and every one of them. I test the game, and the cloning script doesn't work. Why? 30 minutes ago, it was working perfectly fine. I have the script enabled, too.

This script is inside a folder, that's inside Lighting. It has a localscript to clone for every tool inside the folder because a tool will possibly get cloned and sent to a players backpack.

local descendants = script.Parent:GetDescendants()

if script.Parent then
    wait(1)
    for index, descendant in pairs(descendants) do
        if descendant:IsA("Tool") then
            local clone = script.LocalScript:Clone()
            clone.Parent = descendant
        end
    end
    script:Destroy()
end

I'm pretty sure everything in the script is correct. If so, can someone please explain to me why it isn't working? If not, tell me what I'm doing wrong. Help is appreciated.

0
Are you sure the tools aren't given to the players before you run this script, after all it waits for a whole second and only then starts cloning the scripts, the player might've already gotten the tools before the localscript was cloned User#834 0 — 4y
0
No, the tools get cloned from Lighting to Backpack if the player takes an item in Workspace. I added wait(1) to try and fix the problem, but it didn't. I just kept it there. BiIinear 104 — 4y

Answer this question