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

Why must I backspace this tool for it to work?

Asked by
Spooce 78
10 years ago

I have a game pass in my game that gives you a tool, but it doesn't work unless you backspace it and pick it back up. Any way to fix this?

Error: Handle is not a valid member of Tool

No errors with Tool script

Once backspaced it works fine

local function WaitForChild(parent, childName)
    assert(parent, "ERROR: WaitForChild: parent is nil")
    while not parent:FindFirstChild(childName) do parent.ChildAdded:wait() end
    return parent[childName]
end
local GamePassService = game:GetService('GamePassService')
local PlayersService = game:GetService('Players')
local InsertService = game:GetService('InsertService')
local LightingService = game:GetService('Lighting')
local GamePassIdObject = WaitForChild(script, 'GamePassId')
local ToolAssetsToLoad = WaitForChild(script, 'ToolAssetsToLoad')
local AdminTools = LightingService:FindFirstChild('AdminTools')
local function CloneAdminTools(target)
    for _, tool in pairs(AdminTools:GetChildren()) do
        local toolClone = tool:Clone()
        toolClone.Parent = target
    end
end
local function OnPlayerAdded(player)
    if GamePassService:PlayerHasPass(player, GamePassIdObject.Value) then
        local starterGear = WaitForChild(player, 'StarterGear')
        CloneAdminTools(starterGear)
        if player.Character then
            local backpack = WaitForChild(player, 'Backpack')
            CloneAdminTools(backpack)
        end
    end
end
if not AdminTools then
    AdminTools = Instance.new('Model')
    AdminTools.Name = 'AdminTools'
    for _, intObject in pairs(ToolAssetsToLoad:GetChildren()) do
        if intObject and intObject:IsA('IntValue') and intObject.Value then
            local assetModel = InsertService:LoadAsset(intObject.Value)
            if assetModel then
                local asset = assetModel:GetChildren()[1]
                if asset then
                    asset.Parent = AdminTools
                end
            end
        end
    end
    AdminTools.Parent = LightingService
end
PlayersService.PlayerAdded:connect(OnPlayerAdded)
0
Make sure that the tool has a part named "Handle". User#348 0 — 10y
0
It does Spooce 78 — 10y

1 answer

Log in to vote
-2
Answered by 10 years ago

Sorry mate, but that script is fine... It's the tool that is messed up.... Hope I saved you time.

Ad

Answer this question