So basically i have code where if you hold down q then you can see players through walls using the highlight feature that has been created recently but my problem is where when its disabled one of the dummys is still left using it now i tested it with more characters it just seems to iterate through twice and not more
local UserInputService = game:GetService("UserInputService")
local CurrentCamera = workspace.CurrentCamera
local Keycode = Enum.KeyCode.Q
local ActivationSound = script:WaitForChild("SoundEffect")
local FillColor = Color3.fromRGB(28, 255, 43)
local OutlineColor = Color3.fromRGB(13, 13, 13)
function PlayerHeat(Removal)
for i, model in pairs(workspace:GetChildren()) do
if model:FindFirstChild("Humanoid") and model ~= script.Parent then
local Character = model
if Removal and Character:FindFirstChildOfClass("Highlight") then
for i, model in pairs(workspace:GetChildren()) do
if model:FindFirstChild("HumanoidRootPart") then
print(model)
print(model:FindFirstChildOfClass("Highlight"))
model:FindFirstChildOfClass("Highlight"):Destroy()
if not game.Lighting:FindFirstChild("HeatCorrection") then return end
game.Lighting:FindFirstChild("HeatCorrection"):Destroy()
end
end
end
local NewHighlight = Instance.new("Highlight")
NewHighlight.Adornee = Character
NewHighlight.DepthMode = Enum.HighlightDepthMode.AlwaysOnTop
NewHighlight.Enabled = true
NewHighlight.FillColor = FillColor
NewHighlight.OutlineColor = OutlineColor
NewHighlight.FillTransparency = 0
NewHighlight.OutlineTransparency = 0
NewHighlight.Parent = Character
end
end
local CorrectionClone = script.ColorCorrection:Clone()
CorrectionClone.Name = "HeatCorrection"
CorrectionClone.Parent = game.Lighting
end
function FieldOfViewMod(FOV)
CurrentCamera.FieldOfView = FOV
end
UserInputService.InputBegan:Connect(function(input, processed)
if processed then return end
if input.KeyCode == Keycode then
PlayerHeat(false)
FieldOfViewMod(45)
ActivationSound:Play()
end
end)
UserInputService.InputEnded:Connect(function(input, processed)
if processed then return end
if input.KeyCode == Keycode then
PlayerHeat(true)
FieldOfViewMod(70)
return
end
end)
