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

Why are my tools disappearing?

Asked by 10 years ago

So, I have a mapchanger that I'm scripting, and for some reason my tools disappear when I try to equip them once I change the mode.

I have one script that initializes the modes, and handles new players

_G.mode = ""

_G.modes = {
    rcl = {game.ServerStorage:WaitForChild("GPR"), game.ServerStorage:WaitForChild("PSTL")},
    reapers = {game.ServerStorage:WaitForChild("Reaper-7")},
    swords = {game.ServerStorage:WaitForChild("Sword")},
    warc = {game.ServerStorage:WaitForChild("W17"), game.ServerStorage:WaitForChild("Y14")}
}

game.Players.PlayerAdded:connect(function(plyr)
    if _G.mode ~= "" then
        for i,v in pairs(_G.modes[_G.mode]) do
            v:Clone().Parent = plyr.StarterGear
        end
        wait(1)
        plyr:LoadCharacter()
    end
end)

Then, in a module script, I set the mode like so, using a chat command:

commands.setmode = function(args, speaker)
    if #args == 1 then
        _G.mode = args[1]
        for i,v in pairs(game.Players:GetChildren()) do
            v.StarterGear:ClearAllChildren()
            for k,x in pairs(_G.modes[_G.mode]) do
                local clone = x:Clone()
                x.Parent = v.StarterGear
            end
            v:LoadCharacter()
            commands.error({"Mode changed to " .. args[1]}, v)
        end
    else
        commands.error({"Cannot have multiple modes"}, speaker)
    end
end

I know I need to do some more checks in the second one, but when testing with valid modes the tools are parented to the StarterGear fine, yet when I try to equip them the handle is invisible/nonexistent and the tool doesn't work. Any help?

0
Sounds like it's a problem with the tools, are all the parts in the tool unanchored? Is the tool welded? Is Handle spelled properly? Check to make sure the tools work without the script. BlackJPI 2658 — 10y
0
They work without the script just fine. Rapster2 0 — 10y

Answer this question