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

How to clone localscript from workspace to player and make it run?

Asked by 5 years ago

I have a module script that when required should clone the local script to the specified player.

Here is the module:

local module = {}

function module.log(plr)
    script.LocalScript:Clone().Parent = game.Players[plr].Backpack
end

return module

Followed by what the local script inside the module should do after its parented:

for i,v in pairs(game.Players:GetPlayers()) do
    if v.Name == script.Parent.Parent.Name then
        print("Oh good!")
    end
end

And also the script requiring the module script:

wait(3)

require(game.Workspace.ModuleScript).log("CALEBBEN3")

Any help on this would be amazing. Thanks :)

0
Make sure the script is disabled, and enable it after cloning. Or even better, put the script in StarterPlayerScripts, and enable it when necessary. sleazel 1287 — 5y
0
Ok so after its cloned, activate it? CALEBBEN3 -3 — 5y

Answer this question