-- Local script for firing event
local UserInputService = game:GetService("UserInputService")
local Character = script.Parent
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
local TimeStopEvent = script:WaitForChild("TimeStopEvent")
local Cooldown = script:WaitForChild("Cooldown")
UserInputService.InputBegan:Connect(function(input, processed)
if Cooldown.Value == true or processed == true then return end
if input.KeyCode == Enum.KeyCode.H then
TimeStopEvent:FireServer(HumanoidRootPart)
else
return
end
end)
-- Server Script after firing event
local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")
local SoundService = game:GetService("SoundService")
local Debris = game:GetService("Debris")
local Lighting = game:GetService("Lighting")
local ColorCorrection = Lighting:WaitForChild("ColorCorrection")
local TimeStopEvent = script.Parent
local ResumeTime_Sound = script:WaitForChild("ResumeTime")
local StopTime_Sound = script:WaitForChild("StopTime")
local Anchored_Parts = {}
local Scripts = {}
local Humanoid = script.Parent.Parent.Parent:WaitForChild("Humanoid")
local Cooldown = TimeStopEvent.Parent:WaitForChild("Cooldown")
local function ResumeTime(TimeStop_AOE)
TweenService:Create(ColorCorrection, TweenInfo.new(3, Enum.EasingStyle.Linear), {Saturation = 0}):Play()
for i, Part in Anchored_Parts do
print(Part, i)
print(Anchored_Parts)
Part.Anchored = false
table.remove(Anchored_Parts, i)
end
for i, Loop_Script in Scripts do
Loop_Script.Enabled = true
table.remove(Scripts, i)
end
if TimeStop_AOE == nil then return end
TimeStop_AOE:Destroy()
end
local function StopTime(HRP, TimeStop_AOE)
local StopTime_Sound_Clone = StopTime_Sound:Clone()
StopTime_Sound_Clone.Parent = HRP
StopTime_Sound_Clone:Play()
StopTime_Sound_Clone.Ended:Connect(function()
for i = 10, 0, -1 do
if i <= 0 then
local ResumeTime_Sound_Clone = ResumeTime_Sound:Clone()
ResumeTime_Sound_Clone.Parent = HRP
ResumeTime_Sound_Clone:Play()
ResumeTime(TimeStop_AOE)
Debris:AddItem(ResumeTime_Sound_Clone, 2)
Debris:AddItem(StopTime_Sound_Clone, 3)
break
else
print(i)
i -= 1
task.wait(1)
end
end
end)
end
TimeStopEvent.OnServerEvent:Connect(function(player, HRP)
Cooldown.Value = true
local TimeStop_AOE = Instance.new("Part")
TimeStop_AOE.Shape = Enum.PartType.Ball
TimeStop_AOE.CastShadow = false
TimeStop_AOE.Anchored = true
TimeStop_AOE.CanCollide = false
TimeStop_AOE.Position = HRP.Position
TimeStop_AOE.Size = Vector3.new(0.1, 0.1, 0.1)
TimeStop_AOE.Transparency = 0.85
TimeStop_AOE.Material = Enum.Material.Neon
TimeStop_AOE.Name = "TimeStop_AOE"
TimeStop_AOE.Parent = game.Workspace
task.spawn(function()
TweenService:Create(TimeStop_AOE, TweenInfo.new(3, Enum.EasingStyle.Linear), {Size = Vector3.new(750, 750, 750)}):Play()
TweenService:Create(ColorCorrection, TweenInfo.new(3, Enum.EasingStyle.Linear), {Saturation = -1}):Play()
end)
TimeStop_AOE.Touched:Connect(function(hit)
for i, v in hit.Parent:GetDescendants() do
if not hit.Parent:FindFirstChild("Humanoid") then continue end
if v:IsA("Part") and v.Anchored == false then
if not v:IsDescendantOf(player.Character) then
if v.Name == "HumanoidRootPart" then continue end
print(v.Name)
print(Anchored_Parts)
v.Anchored = true
table.insert(Anchored_Parts, v)
elseif v:IsA("Script") or v:IsA("LocalScript") then
print(v.Name)
print(Scripts)
v.Enabled = false
table.insert(Scripts, v)
end
end
end
end)
StopTime(HRP, TimeStop_AOE)
task.wait(35)
Cooldown.Value = false
end)
Humanoid.Died:Connect(function()
ResumeTime(game.Workspace:FindFirstChild("TimeStop_AOE"))
ColorCorrection.Saturation = 0
end)
This script was so close to working until something strange started happening? Whenever I tried to remove the anchored parts from the Anchored_Parts, It only removed some and I tested this many times using print statements. It remove some and not everything from the table. (I used a function to remove them from the table) I’m not sure if this is my fault or roblox’s fault? I tested this on a Noob NPC.