Hello! I’m basically making a security scanner, which checks whether the player has weapons (tools) or not. Then, it changes the screen’s text.
However, it doesn’t change the text. Nothing appears, basically. I even tried removing the second part of the script (for i, v in pairs(characterTools)), but that didn’t help either.
local part = script.Parent
local statusText = part.Parent.Screen.SurfaceGui:WaitForChild("ImageLabel"):WaitForChild("Status")
local YESsound = part.Parent.Sound:WaitForChild("YES")
local NOsound = part.Parent.Sound:WaitForChild("NO")
local DEBOUNCE = false
local characterToolCount = 0
local function onPartTouched(otherPart)
if DEBOUNCE == false then
DEBOUNCE = true
local humanoid = otherPart.Parent:FindFirstChild("Humanoid")
if humanoid then
local who = game.Players:FindFirstChild(otherPart.Parent.Name)
local tools = who.Backpack:GetChildren()
local characterTools = who.Parent:GetChildren()
for i in pairs(tools) do
if tonumber(#tools) >= 1 then
statusText.Text = "YES"
statusText.TextColor3 = Color3.fromRGB(170, 0, 0)
elseif tonumber(#tools) == 0 then
statusText.Text = "NO"
statusText.TextColor3 = Color3.fromRGB(85, 255, 0)
end
break
end
for i, v in pairs(characterTools) do
if v.ClassName == "Model" and v:FindFirstChild("AimPart") then
characterToolCount += 1
end
if characterToolCount >= 1 then
YESsound:Play()
wait(2)
statusText.Text = ""
elseif characterToolCount == 0 and tonumber(#tools) == 0 then
NOsound:Play()
wait(2)
statusText.Text = ""
elseif characterToolCount == 0 and tonumber(#tools) >= 1 then
YESsound:Play()
wait(2)
statusText.Text = ""
end
break
end
end
characterToolCount = 0
wait(1)
DEBOUNCE = false
end
end
part.Touched:Connect(onPartTouched)