#tool disappears when equipped(with script)

1 messages · Page 1 of 1 (latest)

prisma urchin
#

script one:

local remotes=script.Parent.Remotes

remotes.ToolAddUnAdd.OnServerEvent:Connect(function(plr,add,tool)
    if add==true then
        plr.Character.AmountOfTools.Value+=1
    else
        tool:Remove()
        plr.Character.AmountOfTools.Value-=1
    end
end)

remotes.EquipTool.OnServerEvent:Connect(function(plr,id)
    for i,tool in pairs(plr.Backpack:GetChildren()) do
        if tool:IsA("Tool") then
            if tool.ID.Value==id then
                plr.Character:FindFirstChildWhichIsA("Humanoid"):EquipTool(tool)
            end
        end
    end
end)
#

script two:

local plr = game.Players.LocalPlayer
local char=plr.Character
local amountoftools=char.AmountOfTools
local maxtools=char.MaxTools
local gui=script.Parent
local backpacks=gui.Backpack
local remotes=gui.Remotes
local toolthere=gui.ToolsThere
local tweenservice=game:GetService("TweenService")
local inputsevice=game:GetService("UserInputService")

-------------------------------------------------------------------
local StarterGui = game:GetService("StarterGui")
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Health, false)
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
-------------------------------------------------------------------

local function ItemLoader(tool)
    local GuiTool=script.Tool:Clone()
    GuiTool.Parent=backpacks.Items
    GuiTool.ToolName.Text=tool.Name
    if tool.TextureId ~= nil then
        GuiTool.Icon.Image=tool.TextureId
    end
    remotes.ToolAddUnAdd:FireServer(true,tool)
    toolthere.Value+=1
    GuiTool.Count.Value=toolthere.Value
    GuiTool.Name=tool.Name
    GuiTool.ToolId.Value=tool.ID.Value
end

for i,v in pairs(plr.Backpack:GetChildren()) do
    if v:IsA("Tool") then
        ItemLoader(v)
    end
end

plr.Backpack.DescendantAdded:Connect(function(tool)
    if tool:IsA("Tool") then
        ItemLoader(tool)
    end
end)

plr.Backpack.DescendantRemoving:Connect(function(tool)
    if tool:IsA("Tool") then
        remotes.ToolAddUnAdd:FireServer(false,tool)
        toolthere.Value-=1
        for i,v in pairs(backpacks.Items:GetChildren()) do
            if v:IsA("Frame") then
                if v.ToolId.Value==tool.ID.Value then
                    v:Destroy()
                end
            end
        end

    end
end)

amountoftools.Changed:Connect(function()
    local scale=amountoftools.Value/maxtools.Value
    tweenservice:Create(gui.Backpack.Amount.bar,TweenInfo.new(1,Enum.EasingStyle.Cubic,Enum.EasingDirection.Out),{Size = UDim2.new(scale,0,1,0) }):Play()
end)
#

continue of script two:


inputsevice.InputBegan:Connect(function(key,uncan)
    for i,v in pairs(backpacks.Items:GetChildren()) do
        if v:IsA("Frame") then
            local numberToKey = {
                [1] = Enum.KeyCode.One,
                [2] = Enum.KeyCode.Two,
                [3] = Enum.KeyCode.Three,
                [4] = Enum.KeyCode.Four,
                [5] = Enum.KeyCode.Five,
                [6] = Enum.KeyCode.Six,
                [7] = Enum.KeyCode.Seven,
                [8] = Enum.KeyCode.Eight,
                [9] = Enum.KeyCode.Nine,
                [10] = Enum.KeyCode.Zero,
            }
            if key.KeyCode == numberToKey[v.Count.Value] and not uncan then
                remotes.EquipTool:FireServer(v.ToolId.Value)
            end
        end
    end
end)
prisma urchin
#

tool disappears when equipped(with script)

prisma urchin
prisma urchin
#

yes

#

the tool.. just disappears

#

after being equipped

limpid turret
# prisma urchin yes

even this?

remotes.ToolAddUnAdd.OnServerEvent:Connect(function(plr,add,tool)
    if add==true then
        plr.Character.AmountOfTools.Value+=1
    else
        tool:Remove()
        plr.Character.AmountOfTools.Value-=1
    end
end)
prisma urchin
#

wait a minute

limpid turret
#

also why do you have a arg that says "add"????

#

if it gets automatically equipped?

#

*added

prisma urchin
#

yes, its does humanoid:equip

#

OHHH

#

oho

#

OH

#

OHHH

prisma urchin
#

it would cost me more time to notice this thing

#

thanks

#

im stupid

#

im supa blind