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

How do I force equip a gear?

Asked by 3 years ago

Hello, I was wondering If there is anyway to force the player to equip a gear in the Backpack and not unequip it. Anything would help, thanks.

2 answers

Log in to vote
1
Answered by 3 years ago
Edited 3 years ago

This checks the character for any tools that are not supposed to be equipped and equips the tool with the name of ToolName

local Players = game:GetService("Players")
while true do
    wait()
    pcall(function()
        local ToolName = ("Name here")
        local Character = Players.LocalPlayer.Character
        local Humanoid = Instance.new("Humanoid")
        for i,v in pairs(Character:GetChildren()) do
            local t = {}
            if v:IsA("Tool") then
                table.insert(t,v)
            end
            if #t >= 2 then
                Humanoid:UnequipTools()
            end
        end
        Humanoid:EquipTool(Player:FindFirstChildOfClass("Backpack")[ToolName])
    end)
end
0
It doesn't seem to be working for me. Is there anything I should make sure i'm doing? OneRedStar 4 — 3y
0
Make it a LocalScript in StarterPlayer.StarterCharacterScripts? TheLuminent 1204 — 3y
0
I have Tried That, My tool is in StarterPack. Is that the right place? OneRedStar 4 — 3y
Ad
Log in to vote
0
Answered by
raid6n 2196 Moderation Voter Community Moderator
3 years ago
Edited 3 years ago

you can find more information here

local Players = game:GetService("Players")

local player = Players:FindFirstChildOfClass("Players")
if player and player.Character then
    local humanoid = player.Character:FindFirstChildOfClass("Humanoid")
    if humanoid then
        local tool = game.ServerStorage:FindFirstChild("Tool")
        if tool then
            humanoid:EquipTool(tool)
        end
    end
end

Answer this question