Why Does My LocalScript Not Work When Cloned Into A Player's Backpack?
Asked by
7 years ago Edited 7 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:
02 | GUI = script.Parent.Parent |
03 | Player = game.Players.LocalPlayer |
05 | Button.MouseButton 1 Click:connect( function () |
07 | Player.leaderstat.Class.Value = script.Parent.Parent.Parent.Background.Description.Class.Value |
08 | if Player.leaderstat.Class.Value = = "Guardian" then |
09 | local Moves = game.ReplicatedStorage.Guardian:Clone() |
10 | Moves.Parent = Player.Backpack |
12 | Moves.Disabled = false |
13 | elseif Player.leaderstat.Class.Value = = "Warrior" then |
14 | local Moves = game.ReplicatedStorage.Warrior:Clone() |
15 | Moves.Parent = Player.Backpack |
17 | Moves.Disabled = false |
18 | elseif Player.leaderstat.Class.Value = = "Mage" then |
19 | local Moves = game.ReplicatedStorage.Mage:Clone() |
20 | Moves.Parent = Player.Backpack |
22 | Moves.Disabled = false |
In the LocalScript that is being cloned, that isn't working for some reason:
01 | local Player = game.Players.LocalPlayer |
02 | local Character = Player.CharacterAdded:Wait() |
03 | local mouse = Player:GetMouse() |
07 | game:GetService( "UserInputService" ).InputBegan:Connect( function (key) |
08 | if key.KeyCode = = Enum.KeyCode.F and Equipped = = false and UsedOnce = = false then |