Hello everyone!
Me + 1 other person (who helped fix this script when I had a different issue) made this script.
It’s a localScript
local inputServ = game:GetService("UserInputService")
local tweenServ = game:GetService("TweenService")
local canDo = false
local tweenInf = TweenInfo.new(4)
local tween = tweenServ:Create(script.Parent, tweenInf, {Size = UDim2.new(1, 0, 1, 0)})
local LastStart = tick()
spawn(function()
while wait() do
if tick() - LastStart > 4 then
Cancel()
end
end
end)
function Cancel()
LastStart = tick()
tween:Cancel()
script.Parent.Size = UDim2.new(0, 0, 1, 0)
game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart").Anchored = false
end
tween.Completed:Connect(function()
if tick() - LastStart > 2 and tick() - LastStart < 4 then
print("Scanned")
for _, plr in pairs(game.Players:GetPlayers()) do
if plr.Character:WaitForChild("Humanoid") and plr.Name ~= game.Players.LocalPlayer.Name then
local clone = game.ReplicatedStorage.Tag:Clone()
clone.Parent = plr.Character:WaitForChild("Head")
clone.Username.Text = plr.Name
wait(3)
plr.Character.Head.Tag:Destroy()
end
end
end
LastStart = tick()
end)
function Start()
script.Parent.Size = UDim2.new(0, 0, 1, 0)
LastStart = tick()
tween:Play()
script.Parent.Parent.Visible = true
game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart").Anchored = true
end
inputServ.InputBegan:Connect(function(key, chat)
if key.KeyCode == Enum.KeyCode.F and chat ~= true then
Start()
end
end)
inputServ.InputEnded:Connect(function(key)
if key.KeyCode == Enum.KeyCode.F then
Cancel()
end
end)
The “held E, tween done” function runs when the tween is done, but it does not let the player go and reset the bar back to regular so there is a delay. The delay is like 1 or 2 seconds before letting the player go.