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

How to add tool in player backpack using a gui?

Asked by
Xyternal 247 Moderation Voter
2 years ago

Eventually, I'm going to make ranks, and you get different guns for each ranks. I made a script, and guess what? it doesn't work! I'm pretty sure it has A LOT of defects in it. Here is my script, plz help.

local StarterGui = game:GetService('StarterGui') 
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character.Humanoid

local WEAPON = Player.Backpack['M16'] 


local HumanoidRootPart = Character:WaitForChild('HumanoidRootPart')

local GotGun = false
local btn = game.StarterGui.ScreenGui.Frame.TextButton

btn.MouseButton1Click:Connect(function()



        if GotGun == false then
            Humanoid:EquipTool(WEAPON)
            GotGun = true
        end

end)
if Humanoid.Health == 0 then


    Humanoid:UnequipTools()

    GotGun = false
end

0
Saying "my script doesn't work" isn't helpful and won't attract a quick solution. State what it's currently doing, state what it's supposed to do, say potentially what part of it is the issue Shawnyg 4330 — 2y
0
only if you read, you might be able see @Shawnyg Xyternal 247 — 2y

Answer this question