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

StarterGear not Affected by ModuleScript? (Gear not cloning/ not changing the parent instance)

Asked by 5 years ago

I tried modulating some code so it's more streamlined and edit-able. However, the one issue I came upon was in the following code:

Keep in mind, this is in a ModuleScript, called by a parent Script, providing the Player instance and value of Player.Team

local Tools = game.ServerStorage.ToolStorage

local TCDAR = Tools["TCD AR"]
local AR = Tools.AR
local Revolver = Tools.Revolver

local function ClassAssignment(Player, Team)
    local starterGear = Player:WaitForChild("StarterGear")
    starterGear:ClearAllChildren()
    if Team == "TCD" then
        game.Lighting.ClassSystem.ClassCounts.TCD.Assault.Value = game.Lighting.ClassSystem.ClassCounts.TCD.Assault.Value + 1
        local Primary = game.ServerStorage.ToolStorage["TCD AR"]:Clone()
        local Secondary = game.ServerStorage.ToolStorage.Revolver:Clone()
        Primary.Parent = Player.StarterGear
        Secondary.Parent = Player.StarterGear
    elseif Team == "Insurgents" then
        game.Lighting.ClassSystem.ClassCounts.Insurgents.Assault.Value = game.Lighting.ClassSystem.ClassCounts.Insurgents.Assault.Value + 1
        local Primary = AR:Clone()
        local Secondary = Revolver:Clone()
        Primary.Parent = Player.StarterGear
        Secondary.Parent = Player.StarterGear
    end 
    Player.ClassType.Value = "Assault"
    Player:LoadCharacter()
end

return ClassAssignment

The problem lies in either: 1). The tools themselves cloning 2). The tools' copies not being relocated. (I checked both client and server-side and neither showed any sign of the new tools in the player's StarterGear.)

Thanks in advance for any help!

0
“player.Team” is an instance, so try doing Team.Name in the function. Also, is the function running at all? Try putting a print in the function and see if it works. User#20279 0 — 5y
0
Using Team.Name worked, but now I'm having other issues... FortunaAdmin 19 — 5y

Answer this question