Roblox/luau_corpus huggingface dataset:
-- regeneration
function regenHealth()
	if Humanoid.Health == 0 then -- Ded
		regening = false 
		z = Figure:GetChildren() 
		for i= 1, #z do 
			if z[i].ClassName == "Shirt" or z[i].ClassName == "Pants" or z[i].ClassName == "Body Colors" then
				z[i]:Destroy()		
			elseif z[i].ClassName == "Part" then
				part = z[i]		
				part.Transparency = 0.5
				part.BrickColor = BrickColor.new("Deep orange")
				part.Reflectance = 0.2
				lit = Instance.new("PointLight", part)
				lit.Color = Color3.new(1,187/255,28/255)
				bv = Instance.new("BodyVelocity", part)
				bv.velocity = Vector3.new(math.random(-1,1),math.random(-1,1),math.random(-1,1)) 
				part.RotVelocity =  Vector3.new(math.random(-1,1),math.random(-1,1),math.random(-1,1)) 
			elseif z[i].ClassName == "Hat" then
				part = z[i].Handle
				part.Mesh.TextureId = "" 
				part.Transparency = 0.5
				part.Reflectance = 0.2
				part.BrickColor = BrickColor.new("Deep orange")
				lit = Instance.new("PointLight", part)
				lit.Color = Color3.new(1,187/255,28/255)
				bv = Instance.new("BodyVelocity", part)
				bv.velocity = Vector3.new(math.random(-1,1),math.random(-1,1),math.random(-1,1)) 
				part.RotVelocity =  Vector3.new(math.random(-1,1),math.random(-1,1),math.random(-1,1)) 
			end
		end 
		for l = 1, 10 do
			wait(0.3)
				for i= 1, #z do 
				if z[i].ClassName == "Part" then
					z[i].Transparency = z[i].Transparency + 0.08
				elseif z[i].ClassName == "Hat" then
					z[i].Handle.Transparency = z[i].Handle.Transparency + 0.08
					 
				end
			end 
		end
		Figure:Destroy() 
	end
	if regening then return end
	regening = true
	
	while Humanoid.Health < Humanoid.MaxHealth do
		local s = wait(1)
		local health = Humanoid.Health
		if health > 0 and health < Humanoid.MaxHealth then
			local newHealthDelta = 0.01 * s * Humanoid.MaxHealth
			health = health + newHealthDelta
			Humanoid.Health = math.min(health,Humanoid.MaxHealth)
		end
		if Humanoid.Health == 0 then
			game.Debris:AddItem(Figure, 6) 
		end
		
	end
	
	if Humanoid.Health > Humanoid.MaxHealth then
		Humanoid.Health = Humanoid.MaxHealth
	end
	
	
	regening = false
end
local ourtool = nil
function Check()
 tool = nil
		z = char:GetChildren() 
		for i= 1, #z do 
		if z[i].ClassName == "Tool" then
		tool = z[i]
		end
		end 
		if tool == nil then
			if ourtool ~= nil then
			ourtool:Destroy()
			ourtool = nil
			end 
		else
			ourtool = tool:clone()
			ourtool.Parent = Figure
			Humanoid:EquipTool(ourtool)
		end
end
Check()
char.ChildAdded:connect(Check)
char.ChildRemoved:connect(Check)
Humanoid.HealthChanged:connect(regenHealth)
---------------------------
--Seat Offset (Make copies of this block for passenger seats)

car.DriveSeat.ChildAdded:connect(function(child)
	if child.Name=="SeatWeld" and child:IsA("Weld") and game.Players:GetPlayerFromCharacter(child.Part1.Parent)~=nil then
		child.C0=CFrame.new(0,-.5,0)*CFrame.fromEulerAnglesXYZ(-(math.pi/2),0,0)
	end
end)
-- ClientComm
-- Stephen Leitnick
-- December 20, 2021

local Comm = require(script.Parent)
local Util = require(script.Parent.Parent.Util)
local Types = require(script.Parent.Parent.Types)
-- Adds a metatable to a table and all its descending tables

local fullmeta;fullmeta = function(t, meta)
	setmetatable(t, meta)
	for index, other in next, t do
		if type(other) == 'table' then
			fullmeta(other, meta)
		end
	end
	
	return t
end

return fullmeta
-- placed these in here cause yolo
wait(0.1)


ship = script.Parent

r = math.random(1,4)
if r == 1 then
	script.Rocky.angularvelocity = Vector3.new(0.1,0,0)	
elseif r == 2 then
	script.Rocky.angularvelocity = Vector3.new(-0.1,0,0)	
elseif r == 3 then
	script.Rocky.angularvelocity = Vector3.new(0,0,0.1)	
elseif r == 4 then
	script.Rocky.angularvelocity = Vector3.new(0,0,-0.1)
end
script.Rocky:clone().Parent = ship.Engine
ship.Engine.BodyGyro.maxTorque = Vector3.new(0,math.huge,0)
wait(2)
ship.Engine.BodyGyro.maxTorque = Vector3.new(math.huge,math.huge,math.huge)
ship.Engine.Rocky:Destroy()
wait(1)
script:Destroy()
--[[
	Cam Hook
	Allows for clicking and viewing a part
	Phoenix
]]

local Remote = game:GetService("ReplicatedStorage").Game.Events.Game.CameraListener

return function(Environment, ID, Settings)
	script = Environment
	
	local Settings = require(Settings)
	local Players  = {}
	
	script.Parent.MouseClick:Connect(function(Player)
		if Player.Character ~= nil then
			if Player.Character.Humanoid.WalkSpeed > 0 and Player.Character.Humanoid.Health > 0 then
				Players[Player.Name] = Player
				Remote:FireClient(Player, ID, Settings)
			end
		end
	end)
	
	Remote.OnServerEvent:Connect(function(Player, ToID, Command)
		if ToID  == ID then
			if Players[Player.Name] ~= nil then
				if Command == "Finish" then
					Players[Player.Name] = nil
					Player.Character:WaitForChild("HumanoidRootPart").Anchored = false
				elseif Command == "Freeze" then
					Player.Character:WaitForChild("HumanoidRootPart").Anchored = true
				elseif Command == "Resume" then
					Player.Character:WaitForChild("HumanoidRootPart").Anchored = false
				end
			end
		end
	end)
end;
--///////////////// Internal-Use Methods
--//////////////////////////////////////
--DO NOT REMOVE THIS. Chat must be filtered or your game will face
--moderation.
function methods:InternalApplyRobloxFilter(speakerName, message, toSpeakerName) --// USES FFLAG
	if _SETTINGS.DisableSafeChat == true then
		return message
	else
		if (RunService:IsServer() and not RunService:IsStudio()) then
			local fromSpeaker = self:GetSpeaker(speakerName)
			local toSpeaker = toSpeakerName and self:GetSpeaker(toSpeakerName)
	
			if fromSpeaker == nil then
				return nil
			end
	
			local fromPlayerObj = fromSpeaker:GetPlayer()
			local toPlayerObj = toSpeaker and toSpeaker:GetPlayer()
	
			if fromPlayerObj == nil then
				return message
			end
	
			local filterStartTime = tick()
			local filterRetries = 0
			while true do
				local success, message = pcall(function()
					if toPlayerObj then
						return Chat:FilterStringAsync(message, fromPlayerObj, toPlayerObj)
					else
						return Chat:FilterStringForBroadcast(message, fromPlayerObj)
					end
				end)
				if success then
					return message
				else
					warn("Error filtering message:", message)
				end
				filterRetries = filterRetries + 1
				if filterRetries > MAX_FILTER_RETRIES or (tick() - filterStartTime) > MAX_FILTER_DURATION then
					self:InternalNotifyFilterIssue()
					return nil
				end
				local backoffInterval = FILTER_BACKOFF_INTERVALS[math.min(#FILTER_BACKOFF_INTERVALS, filterRetries)]
				-- backoffWait = backoffInterval +/- (0 -> backoffInterval)
				local backoffWait = backoffInterval + ((math.random()*2 - 1) * backoffInterval)
				wait(backoffWait)
			end
		else
			--// Simulate filtering latency.
			--// There is only latency the first time the message is filtered, all following calls will be instant.
			if not StudioMessageFilteredCache[message] then
				StudioMessageFilteredCache[message] = true
				wait()
			end
			return message
		end
	end
	return nil
end
--[[Drivetrain]]	
	Tune.Config			= "AWD"		--"FWD" , "RWD" , "AWD"
	
	--Differential Settings	
	Tune.FDiffSlipThres	= 50		-- 1 - 100%				(Max threshold of applying full lock determined by deviation from avg speed)
	Tune.FDiffLockThres	= 50		-- 0 - 100%				(0 - Bias toward slower wheel, 100 - Bias toward faster wheel)
	Tune.RDiffSlipThres	= 50		-- 1 - 100%
	Tune.RDiffLockThres	= 50		-- 0 - 100%
	Tune.CDiffSlipThres	= 100		-- 1 - 100%				[AWD Only]
	Tune.CDiffLockThres	= 100		-- 0 - 100%				[AWD Only]
	
	--Traction Control Settings
	Tune.TCSEnabled		= false		-- Implements TCS
	Tune.TCSThreshold	= 20		-- Slip speed allowed before TCS starts working (in SPS)
	Tune.TCSGradient	= 20		-- Slip speed gradient between 0 to max reduction (in SPS)
	Tune.TCSLimit		= 10		-- Minimum amount of torque at max reduction (in percent)
--changing transparency
for index, child in pairs(character:GetChildren()) do
	if child:IsA("BasePart") and child.Name ~= "Head" then
		
		child:GetPropertyChangedSignal("LocalTransparencyModifier"):Connect(function()
			child.LocalTransparencyModifier = child.Transparency
		end)
	

	end
end
-- Start of barrier visualization functions
local function getPositionFromVertexList(vertexList)
	return ((vertexList[4] + vertexList[1]) / 2) + ((vertexList[2] - vertexList[1]) / 2)
end
-- Max angle the wheels will reach when turning
-- Higher number means sharper turning, but too high means the wheels might hit the car base
local MAX_TURN_ANGLE = 30
-- MUSIC/SOUNDS
AmbienceSoundEnabled = true
MusicLobbyEnabled = true
GuidingLightMusicEnabled = true
EndingMusicEnabled = true
ElevatorJamMusicEnabled = true
UnhingedMusicEnabled = true
-- Implements Javascript's `Array.prototype.map` as defined below
-- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some
return function<T, U>(t: Array<T>, callback: callbackFn<T> | callbackFnWithThisArg<T, U>, thisArg: U?): boolean
	if typeof(t) ~= "table" then
		error(string.format("Array.some called on %s", typeof(t)))
	end
	if typeof(callback) ~= "function" then
		error("callback is not a function")
	end

	for i, value in t do
		if thisArg ~= nil then
			if value ~= nil and (callback :: callbackFnWithThisArg<T, U>)(thisArg, value, i, t) then
				return true
			end
		else
			if value ~= nil and (callback :: callbackFn<T>)(value, i, t) then
				return true
			end
		end
	end
	return false
end
------------------------------------------------

local function Panned(input, processed)
	if not processed and input.UserInputType == Enum.UserInputType.MouseMovement then
		local delta = input.Delta
		panDeltaMouse = Vector2.new(-delta.y, -delta.x)
	end
end
-- local TITLE_INDENT = '  '
-- local MESSAGE_INDENT = '    '
local STACK_INDENT = "      "
--------------------------CHARACTER CONTROL-------------------------------
local CurrentIgnoreList: {Model}
local CurrentIgnoreTag = nil

local TaggedInstanceAddedConnection: RBXScriptConnection? = nil
local TaggedInstanceRemovedConnection: RBXScriptConnection? = nil

local function GetCharacter(): Model
	return Player and Player.Character
end

local function UpdateIgnoreTag(newIgnoreTag)
	if newIgnoreTag == CurrentIgnoreTag then
		return
	end
	if TaggedInstanceAddedConnection then
		TaggedInstanceAddedConnection:Disconnect()
		TaggedInstanceAddedConnection = nil
	end
	if TaggedInstanceRemovedConnection then
		TaggedInstanceRemovedConnection:Disconnect()
		TaggedInstanceRemovedConnection = nil
	end
	CurrentIgnoreTag = newIgnoreTag
	CurrentIgnoreList = {GetCharacter()}
	if CurrentIgnoreTag ~= nil then
		local ignoreParts = CollectionService:GetTagged(CurrentIgnoreTag)
		for _, ignorePart in ipairs(ignoreParts) do
			table.insert(CurrentIgnoreList, ignorePart)
		end
		TaggedInstanceAddedConnection = CollectionService:GetInstanceAddedSignal(
			CurrentIgnoreTag):Connect(function(ignorePart)
			table.insert(CurrentIgnoreList, ignorePart)
		end)
		TaggedInstanceRemovedConnection = CollectionService:GetInstanceRemovedSignal(
			CurrentIgnoreTag):Connect(function(ignorePart)
			for i = 1, #CurrentIgnoreList do
				if CurrentIgnoreList[i] == ignorePart then
					CurrentIgnoreList[i] = CurrentIgnoreList[#CurrentIgnoreList]
					table.remove(CurrentIgnoreList)
					break
				end
			end
		end)
	end
end

local function getIgnoreList(): {Model}
	if CurrentIgnoreList then
		return CurrentIgnoreList
	end
	CurrentIgnoreList = {}
	table.insert(CurrentIgnoreList, GetCharacter())
	return CurrentIgnoreList
end

local function minV(a: Vector3, b: Vector3)
	return Vector3.new(math.min(a.X, b.X), math.min(a.Y, b.Y), math.min(a.Z, b.Z))
end
local function maxV(a, b)
	return Vector3.new(math.max(a.X, b.X), math.max(a.Y, b.Y), math.max(a.Z, b.Z))
end
local function getCollidableExtentsSize(character: Model?)
	if character == nil or character.PrimaryPart == nil then return end
	local toLocalCFrame = character.PrimaryPart.CFrame:inverse()
	local min = Vector3.new(math.huge, math.huge, math.huge)
	local max = Vector3.new(-math.huge, -math.huge, -math.huge)
	for _,descendant in pairs(character:GetDescendants()) do
		if descendant:IsA('BasePart') and descendant.CanCollide then
			local localCFrame = toLocalCFrame * descendant.CFrame
			local size = Vector3.new(descendant.Size.X / 2, descendant.Size.Y / 2, descendant.Size.Z / 2)
			local vertices = {
				Vector3.new( size.X,  size.Y,  size.Z),
				Vector3.new( size.X,  size.Y, -size.Z),
				Vector3.new( size.X, -size.Y,  size.Z),
				Vector3.new( size.X, -size.Y, -size.Z),
				Vector3.new(-size.X,  size.Y,  size.Z),
				Vector3.new(-size.X,  size.Y, -size.Z),
				Vector3.new(-size.X, -size.Y,  size.Z),
				Vector3.new(-size.X, -size.Y, -size.Z)
			}
			for _,vertex in ipairs(vertices) do
				local v = localCFrame * vertex
				min = minV(min, v)
				max = maxV(max, v)
			end
		end
	end
	local r = max - min
	if r.X < 0 or r.Y < 0 or r.Z < 0 then return nil end
	return r
end
--[[
	Discord - Roblox hookup
	ConfidentCoding
	Do not touch this script.
--]]

local webHook = {}
webHook.__index = webHook

function webHook.new(id,key) 
	local mt = setmetatable({id=id,key=key}, webHook) 
	return mt
end

function webHook:post(config,host)
	local data = nil
	local success = pcall(function()
		data = game:GetService("HttpService"):JSONEncode(config)
	end)
	if not success then warn("Webhook can't be converted to JSON") return end
	game:GetService("HttpService"):PostAsync("https://discordapp.com/api/webhooks/"..self.id.."/"..self.key,data)
end

return webHook
-- Death Messages - Message handler @ JDLENL 3/22/20
-- Please consider accrediting me in the description! It'd be nice of you.
-- This is the part that shows the death messages in chat

game:GetService("ReplicatedStorage"):WaitForChild("DeathMessage").OnClientEvent:Connect(function(Message)
	local s = game:GetService("StarterGui")
	s:SetCore("ChatMakeSystemMessage",{
		Text = Message;
		-- you can change the death message color here: default = red
		Color = Color3.new(1,.2,0);
	})
end)
--Rainbow Sparkling Trail--

local function AttachParticleControl(source_part)
	
	local prtc = nil
	
	local function Start()
		prtc = script.Sparkle:clone()
		prtc.Parent = source_part
	end
	
	local function Update()
		
	end
	
	local function Stop()
		if prtc ~= nil then
			prtc:destroy()
			prtc = nil
		end
	end
	
	return {Start = Start, Update = Update, Stop = Stop}
end

return AttachParticleControl
-- ROBLOX DEVIATION: Ignore enableComponentStackLocations
-- local ReactFeatureFlags = require(script.Parent.ReactFeatureFlags)
-- local enableComponentStackLocations = ReactFeatureFlags.enableComponentStackLocations

local ReactSymbols = require(script.Parent.ReactSymbols)
local REACT_SUSPENSE_TYPE = ReactSymbols.REACT_SUSPENSE_TYPE
local REACT_SUSPENSE_LIST_TYPE = ReactSymbols.REACT_SUSPENSE_LIST_TYPE
local REACT_FORWARD_REF_TYPE = ReactSymbols.REACT_FORWARD_REF_TYPE
local REACT_MEMO_TYPE = ReactSymbols.REACT_MEMO_TYPE
local REACT_BLOCK_TYPE = ReactSymbols.REACT_BLOCK_TYPE
local REACT_LAZY_TYPE = ReactSymbols.REACT_LAZY_TYPE

local ConsolePatchingDev = require(script.Parent["ConsolePatchingDev.roblox"])
local disableLogs = ConsolePatchingDev.disableLogs
local reenableLogs = ConsolePatchingDev.reenableLogs

local ReactSharedInternals = require(script.Parent.ReactSharedInternals)
local ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher
-----------------
--| Functions |--
-----------------

local function OnActivated()
	local myModel = MyPlayer.Character
	if Tool.Enabled and myModel and myModel:FindFirstChild('Humanoid') and myModel.Humanoid.Health > 0 then
		Tool.Enabled = false

		-- Create a clone of Rocket and set its color
		local rocketClone = Rocket:Clone()
		DebrisService:AddItem(rocketClone, 30)
		rocketClone.BrickColor = MyPlayer.TeamColor

		-- Position the rocket clone and launch!
		local spawnPosition = (ToolHandle.CFrame * CFrame.new(2, 0, 0)).p
		rocketClone.CFrame = CFrame.new(spawnPosition, myModel.Humanoid.TargetPoint) --NOTE: This must be done before assigning Parent
		rocketClone.Velocity = rocketClone.CFrame.lookVector * ROCKET_SPEED --NOTE: This should be done before assigning Parent
		rocketClone.Parent = Workspace

		wait(RELOAD_TIME)

		Tool.Enabled = true
	end
end
-- Each note takes up exactly 8 seconds in audio. i.e C2 lasts 8 secs, C2# lasts 8 secs, C3 lasts 8 secs, C3# lasts 8 secs etc. for each audio
-- These are the IDs of the piano sounds.

settings.SoundSource = Piano.Keys.KeyBox

settings.CameraCFrame = CFrame.new(
	(Box.CFrame * CFrame.new(0, 0, 1)).p, -- +z is towards player
	(Box.CFrame * CFrame.new(0, 0, 0)).p
)
-- events

REMOTES.Melee.OnServerEvent:connect(function(player, action, item, ...)
	local character	= player.Character
	if character then
		local equipped	= character.Equipped.Value
		
		if item == equipped then
			if action == "Init" then
				local index		= ...
				local animation	= item.Animations["Attack" .. tostring(index)]
				local timeout	= 0
				
				repeat
					RunService.Stepped:wait()
					for _, track in pairs(character.Humanoid:GetPlayingAnimationTracks()) do
						if track.Animation.AnimationId == animation.AnimationId then
							if track.Length == 0 then
								repeat RunService.Stepped:wait() until track.Length ~= 0
							end
							timeout	= track.Length
							break
						end
					end
				until timeout ~= 0
				
				Init(player, item, timeout)
				
				for _, p in pairs(Players:GetPlayers()) do
					if p ~= player then
						REMOTES.Effect:FireClient(p, "Swing", item, timeout)
					end
				end
			elseif action == "Hit" then
				local info	= inits[player]
				if info then
					if info.Item == item then
						if tick() <= info.Timeout then
							local humanoid	= ...
							if DAMAGE:PlayerCanDamage(player, humanoid) then
								local otherChar	= humanoid.Parent
								local config	= require(item.Config)
								
								local offset	= otherChar.HumanoidRootPart.Position - character.HumanoidRootPart.Position
								local distance	= offset.Magnitude
								
								if distance < MAX_DISTANCE then
									if humanoid.Health > 0 then
										local down	= humanoid:FindFirstChild("Down")
										local alreadyDowned	= false
										
										if down then
											alreadyDowned	= down.Value
										end
										
										local damage	= config.Damage
										DAMAGE:Damage(humanoid, damage, player)
										otherChar.HumanoidRootPart.Velocity	= otherChar.HumanoidRootPart.Velocity + offset.Unit * config.Knockback
										
										local otherPlayer	= Players:GetPlayerFromCharacter(humanoid.Parent)
										if otherPlayer then
											REMOTES.HitIndicator:FireClient(otherPlayer, offset, damage)
										end
										
										if humanoid.Health <= 0 then
											local killDist	= math.floor(offset.Magnitude + 0.5)
											STAT_SCRIPT.FurthestKill:Fire(player, killDist)
											REMOTES.Killfeed:FireAllClients(player.Name, humanoid.Parent.Name, item.Name, killDist)
										end
									end
								end
							end
						end
					end
				end
			end
		end
	end
end)

Players.PlayerRemoving:connect(function(player)
	if inits[player] then
		inits[player]	= nil
	end
end)
-- Boat settings
local BoatSpeed = 6
local TurnSpeed = 0.9
local TiltPower = 4.5*(10^6)

function Examine(Number)
	if Number == 1 then
		return 1
	elseif Number == -1 then
		return 1
	else return Number end
end

while wait() do
--[[ Roblox Services ]]--
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local Workspace = game:GetService("Workspace")
local UserGameSettings = UserSettings():GetService("UserGameSettings")
-------------------------------

local tool = script.Parent
local player = game.Players.LocalPlayer
while player.Character == nil do wait() end
local char = player.Character
while char:FindFirstChild("Humanoid") == nil do wait() end
local hum = char:FindFirstChild("Humanoid")

local enabled = true
local equipped = false
local ischarging = false
local Config = tool:FindFirstChild("Config")
local Direction = Config:FindFirstChild("Direction")
Direction.Value = "Up"

tool.Selected:connect(function(mouse)
	equipped = true
	mouse.Icon = "rbxasset://textures\\GunCursor.png"
	mouse.Button1Down:connect(function()
		if not enabled then return end
		if hum == nil then return end
		if hum.Health <= 0 then return end
		if mouse == nil then return end
		if not ischarging then
			ischarging = true
			enabled = false
			script.Parent.ReleaseProjectile:FireServer(mouse.Hit.p)
			mouse.Icon = "rbxasset://textures\\GunWaitCursor.png"
			wait(RELOAD_TIME)
			mouse.Icon = "rbxasset://textures\\GunCursor.png"
			enabled = true
			ischarging = false
		end
	end)
	mouse.KeyDown:connect(function(key)
		key = key:lower()
		if key == "q" then
			if Direction.Value == "Up" then
				Direction.Value = "Down"
			elseif Direction.Value == "Down" then
				Direction.Value = "Left"
			elseif Direction.Value == "Left" then
				Direction.Value = "Right"
			elseif Direction.Value == "Right" then
				Direction.Value = "Up"
			end
		elseif key == "e" then
			if Direction.Value == "Up" then
				Direction.Value = "Right"
			elseif Direction.Value == "Right" then
				Direction.Value = "Left"
			elseif Direction.Value == "Left" then
				Direction.Value = "Down"
			elseif Direction.Value == "Down" then
				Direction.Value = "Up"
			end
		end
	end)
end)

tool.Deselected:connect(function(mouse)
	equipped = false
end)
--[=[
	Constructs a new Signal

	@return Signal
]=]
function Signal.new<T...>(): Signal<T...>
	local self = setmetatable({
		_handlerListHead = false,
		_proxyHandler = nil,
	}, Signal)
	return self
end
-- initialize to idle
playAnimation("idle", 0.1, AnimController)
pose = "Standing"

while Figure.Parent~=nil do
	local _, time = wait(0.1)
	move(time)
end
--[[
	AntiGravityCoil
	Tool that isn't Tree'd
	Phoenix
]]

local Tool = script.Parent 
local Player = Tool.Parent.Parent
local Died = nil
local Equipped = false

local IsAlive = function()
	if Player.Character then
		if Player.Character:FindFirstChild("Humanoid") then
			if Player.Character:FindFirstChild("Humanoid").Health > 0 then
				return true
			end
		end
	end

	return false
end


local Humanoid = function()
	if Player.Character then
		if Player.Character:FindFirstChild("Humanoid") then
			return Player.Character:FindFirstChild("Humanoid")
		end
	end
end


local Weld = function(From, To)
	local WeldIns = Instance.new("WeldConstraint")
	WeldIns.Part0 = From
	WeldIns.Part1 = To
	WeldIns.Parent = From
	WeldIns.Name = "Weld"
end

local Welding = function(WeldTree, OverrideCenter)
	local Center = nil
	
	if OverrideCenter == nil then
		if WeldTree:FindFirstChildOfClass("MeshPart") then
			Center = WeldTree:FindFirstChildOfClass("MeshPart")
		elseif WeldTree:FindFirstChildOfClass("Part") then
			Center = WeldTree:FindFirstChildOfClass("Part")
		elseif WeldTree:FindFirstChildOfClass("UnionOperation") then
			Center = WeldTree:FindFirstChildOfClass("UnionOperation")
		end
	else
		Center = OverrideCenter
	end

	if Center ~= nil then
		for Index, ToWeld in pairs(WeldTree:GetDescendants()) do
			if ToWeld:IsA("BasePart") then
				Weld(ToWeld, Center)
			end
		end
	else
		print("Could not get a part to weld to! Attempted ".. tostring(WeldTree:GetFullName()).. " By: ".. script:GetFullName())
	end
end


local Enable = function()
	game:GetService("ServerScriptService").Server.Events.ZGSet:Fire(Player, true, false)
end


local Disable = function()
	game:GetService("ServerScriptService").Server.Events.ZGSet:Fire(Player, false, false)
end


Tool.Equipped:Connect(function()
	if Equipped == true then
		return
	end
	
	if IsAlive() == true then
		Equipped = true
		
		Died = Humanoid().Died:Connect(function()
			Disable()
			Died:Disconnect()
			Died = nil
		end)

		Enable()

		Tool.Handle.CoilSound:Play()
	end
end)

Tool.Unequipped:Connect(function()
	if Equipped == false then
		return
	end
	
	Equipped = false
	
	if Died ~= nil then
		Died:Disconnect()
		Died = nil
	end

	Disable()
end)

Welding(Tool.Model, Tool.Handle)
-- Register explorer pane toggling hotkeys
AssignHotkey({ 'LeftShift', 'H' }, ToggleExplorer)
AssignHotkey({ 'RightShift', 'H' }, ToggleExplorer)