Hey! I’ve made a chat command with a script, that checks whether a player has a weapon or not. If the player has a weapon, a text should fade in, fade out and do nothing else. If the player doesn’t have a weapon, his overhead icon should be made visible.
The text fading if player has a weapon works, however it still gives him the icon which it’s not supposed to. Anyone knows how I could fix that?
The code:
local weapons = {}
for i, v in pairs(game.ServerStorage:GetChildren()) do
if v.ClassName == "Tool" and v.Name ~= "Salute" and v.Name ~= "At Ease" and v.Name ~= "BoomBox" and v.Name ~= "Cuffs" and v.Name ~= "Identification" then
table.insert(weapons, tostring(v))
end
end
game.Players.PlayerAdded:Connect(function(Player)
local ClearedValue = Player.PlayerGui:WaitForChild("IsCleared")
local StatusGui = game.StarterGui.StatusText
if Player:IsInGroup(13947653) or Player:IsInGroup(13944389) or Player:IsInGroup(13944487) or Player:IsInGroup(13947692) or Player:IsInGroup(11447389) then
Player.Chatted:Connect(function(Message)
local Words = string.split(Message, " ")
if Words[1] == "!clear" then
for i, v in pairs(weapons) do
if Player.Backpack:FindFirstChild(weapons[i]) then
local CloneStatusGui = StatusGui:Clone()
CloneStatusGui.Parent = Player.PlayerGui
CloneStatusGui.Status.Text = "Player has a weapon!"
CloneStatusGui.Status.Visible = true
for i = 1,0,-0.02 do
wait(0.02)
CloneStatusGui.Status.TextTransparency = i
end
wait(2)
for i = 0,1,0.02 do
wait(0.02)
CloneStatusGui.Status.TextTransparency = i
end
CloneStatusGui:Destroy()
break
elseif not Player.Backpack:FindFirstChild(weapons[i]) then
local NameOfPlayerToClear = Words[2]
local PlayerToClear = NameOfPlayerToClear:lower()
for _, player in ipairs(game:GetService("Players"):GetPlayers()) do
if player.Name:lower():sub(1, #PlayerToClear) == PlayerToClear then
player.Character.Head.GUI.Icons.ClearedIcon.Visible = true
ClearedValue.Value = true
break
end
end
end
end
end
end)
else
print("You're not in a divisional group!")
end
end)