local players = game:GetService("Players")
local gui = script.Parent
local plr = players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local function test()
print("success")
local tweenservice = game:GetService("TweenService")
local UI = gui:WaitForChild("Revive")
local info1 = TweenInfo.new(
0.5, -- Time it takes to fade
Enum.EasingStyle.Circular -- Type of transition
)
local startpoint = {}
startpoint.BackgroundTransparency = (1)
local endPoint1 = {}
endPoint1.BackgroundTransparency = (0)
local fade = tweenservice:Create(UI, info1, endPoint1)
fade:Play()
end
local debounce = false
local CDText = script.Parent:WaitForChild("CountDown"):WaitForChild("TextLabel")
local function countDown()
for i = 20, 0, -1 do
CDText.Text = tostring(i)
task.wait(1)
end
end
workspace:WaitForChild("Part").Touched:Connect(function()
if debounce == false then
debounce = true
local PlayerGui = players.LocalPlayer:WaitForChild("PlayerGui")
gui:WaitForChild("CountDown").Visible = true
gui:WaitForChild("Revive").Visible = true
char:FindFirstChild("HumanoidRootPart").Anchored = true
test()
countDown()
local rem = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent")
hum.Health = 0
task.wait(1)
debounce = false
end
end)
local tweens = game:GetService("TweenService")
local frame = script.Parent
local countDownFrame = frame:WaitForChild("CountDown")
local coutnDownLabel = countDownFrame:WaitForChild("TextLabel")
local players = game:GetService("Players")
local player = players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
local countDown = playerGui:WaitForChild("CountDown")
local revive = playerGui:WaitForChild("Revive")
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local hrp = character:WaitForChild("HumanoidRootPart")
local tweenShow = tweens:Create(revive, TweenInfo.new(0.5, Enum.EasingStyle.Circular, Enum.EasingDirection.Out), {BackgroundTransparency = 1})
local tweenHide = tweens:Create(revive, TweenInfo.new(0.5, Enum.EasingStyle.Circular, Enum.EasingDirection.In), {BackgroundTransparency = 0})
local part = workspace.Part
local debounce = false
local function tweenGuiFrame()
tweenShow:Play()
tweenShow.Completed:Wait()
tweenHide:Play()
tweenHide.Completed:Wait()
end
local function doCountDown()
for i = 20, 0, -1 do
coutnDownLabel.Text = tostring(i)
task.wait(1)
end
end
part.Touched:Connect(function(otherPart)
if debounce then
return
end
if otherPart:IsDescendantOf(character) then
debounce = true
countDown.Visible = true
revive.Visible = true
hrp.Anchored = true
humanoid.Health = 0
tweenGuiFrame()
doCountDown()
task.wait(1)
debounce = false
end
end)
I know this is solved but I just wanted to do some general cleaning up.