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

Why Does My LocalScript Not Work When Cloned Into A Player's Backpack?

I have a script that clones a LocalScript from ServerStorage to a Player's Backpack. The LocalScript works perfectly fine with no errors if I have it in StarterPack when a Player joins the game, but if I clone the LocalScript into a Player's Backpack after they have joined the game, the LocalScript just simply doesn't work. The LocalScript code has no errors and the Script that is putting the LocalScript into the Player's Backpack is just a simple GUI Button that has a Script in it to do so, the LocalScript DOES go into the Backpack, but then, doesn't work like how it should. Any help?

Edit:

Code:

In the Button's LocalScript:

Button = script.Parent
GUI = script.Parent.Parent
Player = game.Players.LocalPlayer

Button.MouseButton1Click:connect(function()
    GUI.Visible = false
    Player.leaderstat.Class.Value = script.Parent.Parent.Parent.Background.Description.Class.Value
    if Player.leaderstat.Class.Value == "Guardian" then
        local Moves = game.ReplicatedStorage.Guardian:Clone()
        Moves.Parent = Player.Backpack
        wait(0.5)
        Moves.Disabled = false
    elseif Player.leaderstat.Class.Value == "Warrior" then
        local Moves = game.ReplicatedStorage.Warrior:Clone()
        Moves.Parent = Player.Backpack
        wait(0.5)
        Moves.Disabled = false
    elseif Player.leaderstat.Class.Value == "Mage" then
        local Moves = game.ReplicatedStorage.Mage:Clone()
        Moves.Parent = Player.Backpack
        wait(0.5)
        Moves.Disabled = false
    end

In the LocalScript that is being cloned, that isn't working for some reason:

local Player = game.Players.LocalPlayer
local Character = Player.CharacterAdded:Wait()
local mouse = Player:GetMouse()
local Equipped = false
local UsedOnce = false

game:GetService("UserInputService").InputBegan:Connect(function(key)
    if key.KeyCode == Enum.KeyCode.F and Equipped ==  false and UsedOnce == false then

---Etc, etc, etc

end)

2 comments

0

Maybe put move the script to ReplicatedStorage, that worked for me

0

tried that, didn't work.

1 answer

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