So when the player presses Z it’s supposed to highlight any players that touch the hitbox for 3 seconds then make the highlight invisible. For some reason it only highlights one player and none of the others, and sometimes it does not highlight them at all.
--//Services\\--
local repStorage = game:GetService("ReplicatedStorage")
local repFirst = game:GetService("ReplicatedFirst")
local UserInputService = game:GetService("UserInputService")
local Lighting = game:GetService("Lighting")
local player = game:GetService("Players").LocalPlayer
local TweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut,0,true,0)
local tweenGoal = {Size=Vector3.new(120,60,120)}
local Assets = repFirst.Assets
local SixthSenseSound = Assets.Sounds.SixthSenseActivate
local SixthSenseHitbox = Assets.SixthSenseHitbox
local SixthSenseLighting = Lighting.SixthSense
local SixthSenseBlur = Lighting.SixthSenseBlur
local highlight = Instance.new("Highlight")
local Activated = false
local debounce = false
local keyPress = Enum.KeyCode.Z -- What button should we press to toggle.
while true do
game.Players.LocalPlayer:GetMouse().KeyDown:Connect(function(key) -- Detects Button Press
local hitboxClone = SixthSenseHitbox:Clone()
if key == "z" and Activated == false then
Activated = true
SixthSenseLighting.Enabled = true
SixthSenseBlur.Enabled = true
SixthSenseSound:Play()
hitboxClone.Parent = player.Character
hitboxClone.CFrame = player.Character.HumanoidRootPart.CFrame
local hitboxTween = TweenService:Create(hitboxClone,tweenInfo,tweenGoal)
hitboxTween:Play()
hitboxClone.Touched:Connect(function(hit)
local target = hit.Parent
if target and target:FindFirstChild("Humanoid") and target.Name ~= player.Character.Name then
if not debounce then
debounce = true
print("Hitbox was touched")
highlight.Parent = target
highlight.FillColor = Color3.fromRGB(94, 222, 96)
highlight.FillTransparency = 0.3
wait(3)
highlight.FillTransparency = 1
debounce = false
end
end
end)
wait(1)
hitboxClone:Destroy()
wait()
Activated = false
SixthSenseLighting.Enabled = false
SixthSenseBlur.Enabled = false
end
end)
wait(5)
end