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

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

Asked by 6 years ago
Edited 6 years ago

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)
0
Maybe put move the script to ReplicatedStorage, that worked for me Fsxfighter265 10 — 6y
0
tried that, didn't work. Wolf5429 15 — 6y

1 answer

Log in to vote
0
Answered by
imaski4 42
6 years ago

hey bub. paste ur code ill fix it up <3

0
There you go. Wolf5429 15 — 6y
Ad

Answer this question