Ah, donāt mind if you try this?
local player = game.Players.LocalPlayer
local countdown = player.PlayerGui:WaitForChild("InGame").Assets.Countdown
local icon = countdown.Icon
local ui = player.PlayerGui:WaitForChild("Notification")
local ts = game:GetService("TweenService")
local text = ui:WaitForChild("Notification")
local runservice = game:GetService("RunService")
local context = game:GetService("ContextActionService")
local sound = workspace.Sound.SFX.BoxSound
local ticksound = workspace.Sound.UI.TickSound
local EndDebounce = false
local debounce = false
local GlobalUISpring = require(game:GetService("ReplicatedFirst").Modules.EzUISpring.GlobalPreset)
text.BackgroundTransparency = 1
text.TextTransparency = 1
local Subject
-- Tweens
local tweenInfo = TweenInfo.new(
0.2,
Enum.EasingStyle.Linear,
Enum.EasingDirection.In
)
local tweenInfo2 = TweenInfo.new(
0.5,
Enum.EasingStyle.Linear,
Enum.EasingDirection.In
)
local opennotif1 = {}
opennotif1.BackgroundTransparency = 0
opennotif1.Position = UDim2.new(0.373, 0, 0.892, 0)
local textnotif1 = {}
textnotif1.TextTransparency = 0
local closenotif1 = {}
closenotif1.BackgroundTransparency = 1
closenotif1.Position = UDim2.new(0.373, 0, 1, 0)
local textnotif2 = {}
textnotif2.TextTransparency = 1
local framein = {}
framein.Position = UDim2.new(0.015, 0, 0.18, 0)
local frameout = {}
frameout.Position = UDim2.new(-1, 0, 0.18, 0)
local vignetteblack = {}
vignetteblack.ImageColor3 = Color3.fromRGB(0, 0, 0)
local vignetteblue = {}
vignetteblue.ImageColor3 = Color3.fromRGB(82, 134, 255)
local vignettegreen = {}
vignettegreen.ImageColor3 = Color3.fromRGB(154, 255, 111)
-- Open Tweens
local opentweens = ts:Create(text, tweenInfo, opennotif1)
local opentweent = ts:Create(text, tweenInfo, textnotif1)
local fin = ts:Create(countdown, tweenInfo2, framein)
-- Close Tweens
local closetweens = ts:Create(text, tweenInfo, closenotif1)
local closetweent = ts:Create(text, tweenInfo, textnotif2)
local fout = ts:Create(countdown, tweenInfo2, frameout)
local vignettereturn = ts:Create(player.PlayerGui:WaitForChild("InGame").Vignette, tweenInfo, vignetteblack)
local vignetteblue = ts:Create(player.PlayerGui:WaitForChild("InGame").Vignette, tweenInfo, vignetteblue)
local vignettegreen = ts:Create(player.PlayerGui:WaitForChild("InGame").Vignette, tweenInfo, vignettegreen)
-- Person In Box
local function SetUpTouched(Object)
local handleAction, runConn
local Hitbox = Object:WaitForChild("hitbox")
local EXIT_RADIUS = Hitbox:GetAttribute("ExitRadius") or 12 -- how far away player needs to be for
Hitbox.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and Subject == nil then
--print("Touched")
Subject = hit
ui.Enabled = true
if script:GetAttribute("enableNotification", true) then
opentweens:Play()
opentweent:Play()
end
context:BindAction("OpenBox", handleAction, true, Enum.KeyCode.E, Enum.KeyCode.ButtonR1)
context:SetPosition("OpenBox", UDim2.new(1, -70, 0, 10))
context:SetImage("OpenBox", "rbxassetid://12768386698")
runConn = runservice.Heartbeat:Connect(function()
local inRadius = true
if Subject.Parent == nil then
inRadius = false
else
local Distance = (Hitbox.Position - Subject.Position).Magnitude
if Distance >= EXIT_RADIUS then
inRadius = false
end
end
if inRadius == false then
runConn:Disconnect()
--print("TouchEnded")
EndDebounce = true
if opentweens.PlaybackState == Enum.PlaybackState.Playing then
opentweens.Completed:Wait()
end
if script:GetAttribute("enableNotification", true) then
closetweens:Play()
closetweent:Play()
end
context:UnbindAction("OpenBox")
task.wait(0.5)
ui.Enabled = false
EndDebounce = false
Subject = nil
end
end)
end
end)
local PowerUp = Hitbox:GetAttribute("PowerUp")
if PowerUp == "JumpBoost" then
handleAction = function(actionName, inputState, _inputObject)
if actionName == "OpenBox" and inputState == Enum.UserInputState.Begin then
context:UnbindAction("OpenBox")
local cvalue = Hitbox:GetAttribute("Countdown")
player.Character:WaitForChild("Humanoid").Died:Connect(function()
cvalue = 0
closetweens:Play()
closetweent:Play()
fout:Play()
countdown.Visible = false
countdown.TextLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
end)
sound:Play()
countdown.Visible = true
player:SetAttribute("PowerUp", PowerUp)
fin:Play()
vignettegreen:Play()
icon.Image = "rbxassetid://14495774882"
local highlight = Instance.new("Highlight")
highlight.Parent = player.Character
highlight.OutlineTransparency = 0.1
highlight.FillTransparency = 1
highlight.OutlineColor = Color3.fromRGB(179, 255, 107)
highlight.OutlineTransparency = 1
local tween1 = ts:Create(highlight, TweenInfo.new(0.5, Enum.EasingStyle.Quint), {OutlineTransparency = 0})
local tween0 = ts:Create(highlight, TweenInfo.new(0.5, Enum.EasingStyle.Quint), {OutlineTransparency = 1})
tween1:Play()
player.Character:WaitForChild("Humanoid").UseJumpPower = true
player.Character:FindFirstChild("Humanoid").JumpPower = 95
Object:FindFirstChild("box").Transparency = 1
Object:FindFirstChild("box"):FindFirstChild("PointLight").Enabled = false
Object:FindFirstChild("box"):FindFirstChild("ParticleEmitter").Enabled = false
Hitbox.CanTouch = false
closetweens:Play()
closetweent:Play()
ui.Enabled = false
repeat
if Object:FindFirstChild("hitbox") == nil then
return
end
countdown.TextLabel.Text = Object:FindFirstChild("hitbox"):GetAttribute("Countdown")
cvalue = cvalue - 1
if cvalue <= 4 then
countdown.TextLabel.TextColor3 = Color3.fromRGB(255, 52, 55)
ticksound:Play()
end
Object:FindFirstChild("hitbox"):SetAttribute("Countdown", cvalue)
task.wait(1)
until
cvalue == 0
if cvalue == 0 then
tween0:Play()
fout:Play()
fout.Completed:Wait()
player:SetAttribute("PowerUp", "")
countdown.Visible = false
vignettereturn:Play()
countdown.TextLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
player.Character:FindFirstChild("Humanoid").JumpPower = 50
tween0.Completed:Wait()
highlight:Destroy()
end
end
end
elseif PowerUp == "SpeedBoost" then
handleAction = function(actionName, inputState, _inputObject)
if actionName == "OpenBox" and inputState == Enum.UserInputState.Begin then
workspace.Gravity = 150
context:UnbindAction("OpenBox")
local cvalue = Object:FindFirstChild("hitbox"):GetAttribute("Countdown")
sound:Play()
countdown.Visible = true
player:SetAttribute("PowerUp", PowerUp)
fin:Play()
icon.Image = "rbxassetid://14495573983"
local highlight = Instance.new("Highlight")
highlight.Parent = player.Character
highlight.OutlineColor = Color3.fromRGB(115, 164, 255)
highlight.FillTransparency = 1
highlight.OutlineTransparency = 1
local tween1 = ts:Create(highlight, TweenInfo.new(0.5, Enum.EasingStyle.Quint), {OutlineTransparency = 0})
local tween0 = ts:Create(highlight, TweenInfo.new(0.5, Enum.EasingStyle.Quint), {OutlineTransparency = 1})
tween1:Play()
vignetteblue:Play()
script.Parent.FOV.FOV.Value = script.Parent.FOV.FOV.Value + 10
player.Character:FindFirstChild("Humanoid").WalkSpeed = 40
Object:FindFirstChild("box").Transparency = 1
Object:FindFirstChild("box"):FindFirstChild("PointLight").Enabled = false
Object:FindFirstChild("box"):FindFirstChild("ParticleEmitter").Enabled = false
Hitbox.CanTouch = false
closetweens:Play()
closetweent:Play()
ui.Enabled = false
repeat
if Object:FindFirstChild("hitbox") == nil then
return
end
countdown.TextLabel.Text = Hitbox:GetAttribute("Countdown")
if cvalue <= 4 then
ticksound:Play()
countdown.TextLabel.TextColor3 = Color3.fromRGB(255, 52, 55)
end
cvalue = cvalue - 1
Hitbox:SetAttribute("Countdown", cvalue)
task.wait(1)
until
cvalue == 0
if cvalue == 0 then
tween0:Play()
workspace.Gravity = 196.2
script.Parent.FOV.FOV.Value = script.Parent.FOV.InitialFOV.Value
fout:Play()
fout.Completed:Wait()
player:SetAttribute("PowerUp", "")
countdown.Visible = false
vignettereturn:Play()
countdown.TextLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
player.Character:FindFirstChild("Humanoid").WalkSpeed = 20
tween0.Completed:Wait()
highlight:Destroy()
end
end
end
player.Character:WaitForChild("Humanoid").Died:Connect(function()
workspace.Gravity = 196.2
local cvalue = Object:FindFirstChild("hitbox"):GetAttribute("Countdown")
fout:Play()
fout.Completed:Wait()
countdown.Visible = false
cvalue = 0
return
end)
end
end
local function FindBoxesRecurring(Object)
if Object.Name == "Box" and Object:isA("Model") then
SetUpTouched(Object)
end
for _, child in pairs(Object:GetChildren()) do
FindBoxesRecurring(child)
end
end
workspace.DescendantAdded:Connect(function(Object)
if Object.Name == "Box" and Object:isA("Model") then
SetUpTouched(Object)
end
end)
FindBoxesRecurring(workspace)