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

2 comments
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
only if you read, you might be able see @Shawnyg