Pinkstack/roblox-luau-corpus-text huggingface dataset:
--NOTE
--The animation can bug out, im still trying to find a way to fix that.



repeat wait() until game:IsLoaded()
wait(0.01)
local TweenService = game:GetService("TweenService") 
local tweenPart = game.Players.LocalPlayer.Character.Humanoid 

local info = TweenInfo.new(
	0.325,          
	Enum.EasingStyle.Back,  
	Enum.EasingDirection.Out,  
	0,                
	false,         
	0             
)
local info2 = TweenInfo.new(
	0.3,   
	Enum.EasingStyle.Back,   
	Enum.EasingDirection.Out,  
	0,               
	false,              
	0               
)

local Goals = {CameraOffset = Vector3.new(0,-1.75,0)}
local Goals2 = {CameraOffset = Vector3.new(0,0,0)}

local animsR6 = script.Parent.Parent.R6Anims
local animsR15 = script.Parent.Parent.R15Anims

local PartTween = TweenService:Create(tweenPart, info, Goals)
local PartTween2 = TweenService:Create(tweenPart, info2, Goals2)

local animidle = tweenPart:LoadAnimation(animsR15.Idle)
local animwalk = tweenPart:LoadAnimation(animsR15.Walk)

if tweenPart.RigType == Enum.HumanoidRigType.R6 then
	animidle = tweenPart:LoadAnimation(animsR6.Idle)
	animwalk = tweenPart:LoadAnimation(animsR6.Walk)
elseif tweenPart.RigType == Enum.HumanoidRigType.R15 then
	animidle = tweenPart:LoadAnimation(animsR15.Idle)
	animwalk = tweenPart:LoadAnimation(animsR15.Walk)
end

local crouching = false
local waiting = false

local function Crouch()
	if waiting == false then
		if crouching == false then
			script.Parent.Parent.ImageColor3 = script.Parent.Parent.Values.OnCrouchColor.Value
			script.Parent.Parent.CrouchImage.ImageColor3 = Color3.new(1, 1, 1)
			tweenPart.WalkSpeed = 8
			waiting = true
			crouching = true
			animidle:Play()
			PartTween:Play() --plays it
			tweenPart.Running:Connect(function(Speed)
				if crouching == true then
					if Speed >= 1 then
						animidle:Stop()
						if animwalk.IsPlaying == false then
							animwalk:Play()
						end

					else
						animidle:Play()
						animwalk:Stop()
					end
				end
			end)
			wait(0.05)
			waiting = false
		else
			script.Parent.Parent.ImageColor3 = script.Parent.Parent.Values.OriginalColor.Value
			script.Parent.Parent.CrouchImage.ImageColor3 = Color3.new(0, 0, 0)
			tweenPart.WalkSpeed = 16
			waiting = true
			crouching = false
			animidle:Stop()
			animwalk:Stop()
			PartTween2:Play()
			wait(0.05)
			waiting = false
		end
	end
end
local userinputservice = game:GetService("UserInputService")
userinputservice.InputBegan:Connect(function(input)
	if script.Parent.Parent.Visible == true then
		if input.KeyCode == Enum.KeyCode.LeftControl then
			Crouch()
		end
	end
end)
script.Parent.Parent.MouseButton1Click:Connect(function()
	Crouch()
end)
--[[Engine]]


	--Torque Curve
	Tune.Horsepower		= 265		--	[TORQUE CURVE VISUAL]
	Tune.IdleRPM		= 700		--		https://www.desmos.com/calculator/2uo3hqwdhf
	Tune.PeakRPM		= 6980		--		Use sliders to manipulate values
	Tune.Redline		= 8000		--		Copy and paste slider values into the respective tune values
	Tune.EqPoint		= 5500
	Tune.PeakSharpness	= 7.5
	Tune.CurveMult		= 0.16
	
	--Incline Compensation
	Tune.InclineComp	= 1.7			-- Torque compensation multiplier for inclines (applies gradient from 0-90 degrees)
	
	--Misc
	Tune.RevAccel		= 150		-- RPM acceleration when clutch is off
	Tune.RevDecay		= 75		-- RPM decay when clutch is off
	Tune.RevBounce		= 500		-- RPM kickback from redline
	Tune.IdleThrottle	= 3			-- Percent throttle at idle
	Tune.ClutchTol		= 500		-- Clutch engagement threshold (higher = faster response)
-- connect events


Humanoid.Died:connect(onDied)
Humanoid.Running:connect(onRunning)
Humanoid.Jumping:connect(onJumping)
Humanoid.Climbing:connect(onClimbing)
Humanoid.GettingUp:connect(onGettingUp)
Humanoid.FreeFalling:connect(onFreeFall)
Humanoid.FallingDown:connect(onFallingDown)
Humanoid.Seated:connect(onSeated)
Humanoid.PlatformStanding:connect(onPlatformStanding)
Humanoid.Swimming:connect(onSwimming)
local runService = game:GetService("RunService");
playAnimation("idle", 0.1, Humanoid)
pose = "Standing"
while wait(0)do
local _,time=wait(0)
move(time)
end
-- If you want to know how to retexture a hat, read this:  http://www.roblox.com/Forum/ShowPost.aspx?PostID=10502388










debounce = true

function onTouched(hit)
	if (hit.Parent:findFirstChild("Humanoid") ~= nil and debounce == true) then
		debounce = false
		h = Instance.new("Hat")
		p = Instance.new("Part")
		h.Name = "Hat"   -- It doesn't make a difference, but if you want to make your place in Explorer neater, change this to the name of your hat.
		p.Parent = h
		p.Position = hit.Parent:findFirstChild("Head").Position
		p.Name = "Handle" 
		p.formFactor = 0
		p.Size = Vector3.new(-0,-0,-1) 
		p.BottomSurface = 0 
		p.TopSurface = 0 
		p.Locked = true 
		script.Parent.Mesh:clone().Parent = p
		h.Parent = hit.Parent
		h.AttachmentPos = Vector3.new(1, 0.56, -0.3) -- Change these to change the positiones of your hat, as I said earlier.
		wait(5)		debounce = true
	end
end

script.Parent.Touched:connect(onTouched)
-- Splits a uint32 number into four bytes.


function common.uint32_to_bytes(a)
	local a4 = a % 256
	a = (a - a4) / 256
	local a3 = a % 256
	a = (a - a3) / 256
	local a2 = a % 256
	local a1 = (a - a2) / 256
	return a1, a2, a3, a4
end

return common
-------- OMG HAX



r = game:service("RunService")


local damage = 0


local slash_damage = 0


sword = script.Parent.Handle
Tool = script.Parent



function attack()
	local anim = Instance.new("StringValue")
	anim.Name = "toolanim"
	anim.Value = "Slash"
	anim.Parent = Tool
end


function swordUp()
	Tool.GripForward = Vector3.new(-1,0,0)
	Tool.GripRight = Vector3.new(0,1,0)
	Tool.GripUp = Vector3.new(0,0,1)
end

function swordOut()
	Tool.GripForward = Vector3.new(0,0,1)
	Tool.GripRight = Vector3.new(0,-1,0)
	Tool.GripUp = Vector3.new(-1,0,0)
end



Tool.Enabled = true

function onActivated()

	if not Tool.Enabled then
		return
	end

	Tool.Enabled = false

	local character = Tool.Parent;
	local humanoid = character.Humanoid
	if humanoid == nil then
		print("Humanoid not found")
		return 
	end

	

	attack()

	wait(1)

	Tool.Enabled = true
end


function onEquipped()
end


script.Parent.Activated:connect(onActivated)
script.Parent.Equipped:connect(onEquipped)
--Objects


local DriverSeat = Chassis.driverSeat

local function unbindActions()
	ContextActionService:UnbindAction(STEER_LEFT_ACTION_NAME)
	ContextActionService:UnbindAction(STEER_RIGHT_ACTION_NAME)
	ContextActionService:UnbindAction(THROTTLE_ACTION_NAME)
	ContextActionService:UnbindAction(BRAKE_ACTION_NAME)
	ContextActionService:UnbindAction(HAND_BRAKE_ACTION_NAME)
	ContextActionService:UnbindAction(EXIT_ACTION_NAME)
end

local function onExitSeat(Seat)
	unbindActions()
	LocalVehicleSeating.DisconnectFromSeatExitEvent(onExitSeat)
	script.Disabled = true
end
LocalVehicleSeating.OnSeatExitEvent(onExitSeat)
--local Player
--local Character
--local Humanoid


local Module = require(Tool:WaitForChild("Setting"))
local ChangeMagAndAmmo = script:WaitForChild("ChangeMagAndAmmo")
local Grip2
local Handle2

if Module.DualEnabled then
	Handle2 = Tool:WaitForChild("Handle2",1)
	if Handle2 == nil and Module.DualEnabled then error("\"Dual\" setting is enabled but \"Handle2\" is missing!") end
end

local MagValue = script:FindFirstChild("Mag") or Instance.new("NumberValue",script)
MagValue.Name = "Mag"
MagValue.Value = Module.AmmoPerMag
local AmmoValue = script:FindFirstChild("Ammo") or Instance.new("NumberValue",script)
AmmoValue.Name = "Ammo"
AmmoValue.Value = Module.LimitedAmmoEnabled and Module.Ammo or 0

if Module.IdleAnimationID ~= nil or Module.DualEnabled then
	local IdleAnim = Instance.new("Animation",Tool)
	IdleAnim.Name = "IdleAnim"
	IdleAnim.AnimationId = "rbxassetid://"..(Module.DualEnabled and 53610688 or Module.IdleAnimationID)
end
if Module.FireAnimationID ~= nil then
	local FireAnim = Instance.new("Animation",Tool)
	FireAnim.Name = "FireAnim"
	FireAnim.AnimationId = "rbxassetid://"..Module.FireAnimationID
end
if Module.ReloadAnimationID ~= nil then
	local ReloadAnim = Instance.new("Animation",Tool)
	ReloadAnim.Name = "ReloadAnim"
	ReloadAnim.AnimationId = "rbxassetid://"..Module.ReloadAnimationID
end
if Module.ShotgunClipinAnimationID ~= nil then
	local ShotgunClipinAnim = Instance.new("Animation",Tool)
	ShotgunClipinAnim.Name = "ShotgunClipinAnim"
	ShotgunClipinAnim.AnimationId = "rbxassetid://"..Module.ShotgunClipinAnimationID
end
if Module.HoldDownAnimationID ~= nil then
	local HoldDownAnim = Instance.new("Animation",Tool)
	HoldDownAnim.Name = "HoldDownAnim"
	HoldDownAnim.AnimationId = "rbxassetid://"..Module.HoldDownAnimationID
end
if Module.EquippedAnimationID ~= nil then
	local EquippedAnim = Instance.new("Animation",Tool)
	EquippedAnim.Name = "EquippedAnim"
	EquippedAnim.AnimationId = "rbxassetid://"..Module.EquippedAnimationID
end

ChangeMagAndAmmo.OnServerEvent:connect(function(Player,Mag,Ammo)
	MagValue.Value = Mag
	AmmoValue.Value = Ammo
end)

Tool.Equipped:connect(function()
	--Player = game.Players:GetPlayerFromCharacter(Tool.Parent)
	--Character = Tool.Parent
	--Humanoid = Character:FindFirstChild("Humanoid")
	if Module.DualEnabled and workspace.FilteringEnabled then
		Handle2.CanCollide = false
		local LeftArm = Tool.Parent:FindFirstChild("Left Arm") or Tool.Parent:FindFirstChild("LeftHand")
		local RightArm = Tool.Parent:FindFirstChild("Right Arm") or Tool.Parent:FindFirstChild("RightHand")
		if RightArm then
			local Grip = RightArm:WaitForChild("RightGrip",0.01)
			if Grip then
				Grip2 = Grip:Clone()
				Grip2.Name = "LeftGrip"
				Grip2.Part0 = LeftArm
				Grip2.Part1 = Handle2
				--Grip2.C1 = Grip2.C1:inverse()
				Grip2.Parent = LeftArm
			end
		end
	end
end)

Tool.Unequipped:connect(function()
	if Module.DualEnabled and workspace.FilteringEnabled then
		Handle2.CanCollide = true
		if Grip2 then Grip2:Destroy() end
	end
end)
--Dont mess with any of this


function boop(Player)
	if not Player.Backpack:FindFirstChild(Toolname) then
		local Tool = game.ServerStorage[Toolname]:clone()
		Tool.Parent = Player.Backpack
		script.Parent.ClickDetector.MaxActivationDistance = 0
		game.Workspace.Crowbarmod.Transparency = 1
		wait(100)
		game.Workspace.Crowbarmod.Transparency = 0
		script.Parent.ClickDetector.MaxActivationDistance = 5
	end
end
script.Parent.ClickDetector.MouseClick:connect(boop)
-- InspiringNote's free to use rank GUI/script.




local groupID = 16072157 -- Put your Group ID here!


game.Players.PlayerAdded:Connect(function(player)
	local groupRank = player:GetRoleInGroup(groupID)
	local clone = script.Rank:Clone()
	clone.Parent = game.Workspace:WaitForChild(player.Name).Head
	clone.Frame.Name1.Text = player.Name
	clone.Frame.Rank.Text = groupRank
	
	player.CharacterAdded:Connect(function()
		local groupRank = player:GetRoleInGroup(groupID)
		local clone = script.Rank:Clone()
		clone.Parent = game.Workspace:WaitForChild(player.Name).Head
		clone.Frame.Name1.Text = player.Name
		clone.Frame.Rank.Text = groupRank
	end)


end)
--//D//--


if gear.Value == 1 then
if script.Parent.TC.On.Value == true then
if carSeat.Throttle == 1 and script.Parent.CC.Value == true then
	rwd.Torque = 0
	lwd.Torque = 0
	rrwd.Torque = 0
	rwd.Throttle = 0
	lwd.Throttle = 0
	rrwd.Throttle = 0
	elseif carSeat.Throttle == 1 and script.Parent.CC.Value == false then
	rwd.Throttle = 0
	rwd.Torque = 0
	rwd.MaxSpeed = maxspeed
	lwd.Throttle = 0
	lwd.Torque = 0
	lwd.MaxSpeed = maxspeed
	rrwd.Throttle = 0
	rrwd.Torque = 0
	rrwd.MaxSpeed = maxspeed
	
elseif carSeat.Throttle == -1 then
	script.Parent.CC.Value = false
	rb.RB.CanCollide = true
	rb.FB.CanCollide = true
	lfb.RB.CanCollide = true
	lfb.FB.CanCollide = true
	rfb.RB.CanCollide = true
	rfb.FB.CanCollide = true
	wait(brakes)
	rb.RB.CanCollide = false
	rb.FB.CanCollide = false
	lfb.RB.CanCollide = false
	lfb.FB.CanCollide = false
	rfb.RB.CanCollide = false
	rfb.FB.CanCollide = false
	wait()
elseif carSeat.Throttle == 0 and script.Parent.CC.Value == true then
	rb.RB.CanCollide = false
	rb.FB.CanCollide = false
	lfb.RB.CanCollide = false
	lfb.FB.CanCollide = false
	rfb.RB.CanCollide = false
	rfb.FB.CanCollide = false
	elseif carSeat.Throttle == 0 and script.Parent.CC.Value == false then
	rwd.Throttle = 0
	rwd.Torque = cst
	rwd.MaxSpeed = maxspeed
	lwd.Throttle = 0
	lwd.Torque = cst
	lwd.MaxSpeed = maxspeed
	rrwd.Throttle = 0
	rrwd.Torque = cst
	rrwd.MaxSpeed = maxspeed
	rb.RB.CanCollide = false
	rb.FB.CanCollide = false
	lfb.RB.CanCollide = false
	lfb.FB.CanCollide = false
	rfb.RB.CanCollide = false
	rfb.FB.CanCollide = false
	end
end

if script.Parent.TC.On.Value == false then
	if carSeat.Throttle == 1 and script.Parent.CC.Value == true then
	rwd.Torque = tq
	lwd.Torque = ftq
	rrwd.Torque = ftq
	rwd.Throttle = 1
	lwd.Throttle = 1
	rrwd.Throttle = 1
	elseif carSeat.Throttle == 1 and script.Parent.CC.Value == false then
	rwd.Throttle = 1
	rwd.Torque = tq
	rwd.MaxSpeed = maxspeed
	lwd.Throttle = 1
	lwd.Torque = ftq
	lwd.MaxSpeed = maxspeed
	rrwd.Throttle = 1
	rrwd.Torque = ftq
	rrwd.MaxSpeed = maxspeed
	
elseif carSeat.Throttle == -1 then
	script.Parent.CC.Value = false
	rb.RB.CanCollide = true
	rb.FB.CanCollide = true
	lfb.RB.CanCollide = true
	lfb.FB.CanCollide = true
	rfb.RB.CanCollide = true
	rfb.FB.CanCollide = true
	wait(brakes)
	rb.RB.CanCollide = false
	rb.FB.CanCollide = false
	lfb.RB.CanCollide = false
	lfb.FB.CanCollide = false
	rfb.RB.CanCollide = false
	rfb.FB.CanCollide = false
	wait()
elseif carSeat.Throttle == 0 and script.Parent.CC.Value == true then
	rb.RB.CanCollide = false
	rb.FB.CanCollide = false
	lfb.RB.CanCollide = false
	lfb.FB.CanCollide = false
	rfb.RB.CanCollide = false
	rfb.FB.CanCollide = false
	elseif carSeat.Throttle == 0 and script.Parent.CC.Value == false then
	rwd.Throttle = 0
	rwd.Torque = cst
	rwd.MaxSpeed = maxspeed
	lwd.Throttle = 0
	lwd.Torque = cst
	lwd.MaxSpeed = maxspeed
	rrwd.Throttle = 0
	rrwd.Torque = cst
	rrwd.MaxSpeed = maxspeed
	rb.RB.CanCollide = false
	rb.FB.CanCollide = false
	lfb.RB.CanCollide = false
	lfb.FB.CanCollide = false
	rfb.RB.CanCollide = false
	rfb.FB.CanCollide = false
	end
end
	end
-- Don't edit if you don't know what you're doing --



local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetOrderedDataStore("GlobalLeaderboard_" .. StatsName)
local SurfaceGui = script.Parent
local Sample = script.Sample
local List = SurfaceGui.Frame.List
local ItemsFrame = List.ListContent.Items

local function GetItems()
	local Data = DataStore:GetSortedAsync(false, MaxItems, MinValueDisplay, MaxValueDisplay)
	local TopPage = Data:GetCurrentPage()
	
	ItemsFrame.Nothing.Visible = #TopPage == 0 and true or false
	
	for i, v in ipairs(TopPage) do
		local UserId = v.key
		local Value = v.value
		local Username = "[Not Available]"
		local Color = Color3.fromRGB(38, 50, 56)
		
		local Success, Error = pcall(function()
		 	Username = game.Players:GetNameFromUserIdAsync(UserId)
		end)
		
		if i == 1 then
			Color = Color3.fromRGB(255, 215, 0)
		elseif i == 2 then
			Color = Color3.fromRGB(192, 192, 192)
		elseif i == 3 then
			Color = Color3.fromRGB(205, 127, 50)
		end
		
		local Item = Sample:Clone()
		Item.Name = Username
		Item.LayoutOrder = i
		Item.Values.Number.TextColor3 = Color
		Item.Values.Number.Text = i
		Item.Values.Username.Text = Username
		Item.Values.Value.Text = Value
		Item.Parent = ItemsFrame
	end
end

while true do
	for i, v in pairs(game.Players:GetPlayers()) do
		local Stats = v.leaderstats:WaitForChild(StatsName).Value
		if Stats then
			pcall(function()
				DataStore:UpdateAsync(v.UserId, function(Value)
					return tonumber(Stats)
				end)
			end)
		end
	end
	
	for i, v in pairs(ItemsFrame:GetChildren()) do
		if v:IsA("ImageLabel") then
			v:Destroy()
		end
	end
	
	GetItems()
	
	wait()
	SurfaceGui.Heading.Heading.Text = StatsName .. " Leaderboard"
	List.ListContent.GuideTopBar.Value.Text = StatsName
	List.CanvasSize = UDim2.new(0, 0, 0, ItemsFrame.UIListLayout.AbsoluteContentSize.Y + 35)
	wait(UpdateEvery)
end
-- Helpers to patch console.logs to avoid logging during side-effect free
-- replaying on render function. This currently only patches the object
-- lazily which won't cover if the log function was extracted eagerly.
-- We could also eagerly patch the method.


local disabledDepth = 0
local prevLog
local prevInfo
local prevWarn
local prevError
local prevGroup
local prevGroupCollapsed
local prevGroupEnd

local disabledLog = function() end

local exports = {}
--[[
	ControlModule - This ModuleScript implements a singleton class to manage the
	selection, activation, and deactivation of the current character movement controller.
	This script binds to RenderStepped at Input priority and calls the Update() methods
	on the active controller instances.
	
	The character controller ModuleScripts implement classes which are instantiated and
	activated as-needed, they are no longer all instantiated up front as they were in
	the previous generation of PlayerScripts.
	
	2018 PlayerScripts Update - AllYourBlox		
--]]


local ControlModule = {}
ControlModule.__index = ControlModule
--				if Zdir < 0 then -- Get closest 45 degree angle. Diagonal.
--					Zdag = -RAYLength
--				else
--					Zdag = RAYLength
--				end
--				if Xdir < 0 then
--					Xdag = -RAYLength
--				else
--					Xdag = RAYLength
--				end



				if math.abs(Xdir) > math.abs(Zdir) then  -- Ordinal.
					if Xdir < 0 then 
						Xdir = -RAYLength          
						-- convert to our direction indicator.  
					else
						Xdir = RAYLength
					end
					Zdag = Xdir -- Diagonal Right.
					Xdag = Xdir
					Zdir = 0
				else   -- abs
					if Zdir < 0 then
						Zdir = -RAYLength	
					else                                  
						Zdir = RAYLength
					end
					Zdag = Zdir
					Xdag = -Zdir
					Xdir = 0 
				end  -- abs
end -- GetDir


while AItorso do -- while I still have a body; search.
torsoPos = AItorso.Position
local targ = Workspace.Terrain  -- Temp targ
local Distance =(torsoPos - OldPos).magnitude -- Distance traveled, since last loop
-- ScreenSpace -> WorldSpace. Taking a screen height, and a depth to put an object
-- at, and returning a size of how big that object has to be to appear that size
-- at that depth.


function ScreenSpace.ScreenToWorldByHeightDepth(x, y, screenHeight, depth)
	local aspectRatio = ScreenSpace.AspectRatio()
	local hfactor = math.tan(math.rad(workspace.CurrentCamera.FieldOfView)/2)
	local wfactor = aspectRatio*hfactor
	local sx, sy = ScreenSpace.ViewSizeX(), ScreenSpace.ViewSizeY()
	--
	local worldHeight = -(screenHeight/sy) * 2 * hfactor * depth
	--
	local xf, yf = x/sx*2 - 1, y/sy*2 - 1
	local xpos = xf * -wfactor * depth
	local ypos = yf *  hfactor * depth
	--
	return Vector3.new(xpos, ypos, depth), worldHeight
end
-- regeneration


while true do
	local s = wait(0.01)
	local health = Humanoid.Health
	if health > 0 and health < Humanoid.MaxHealth then
		health = health + 0.1 * s * Humanoid.MaxHealth
		if health * 1.05 < Humanoid.MaxHealth then
			Humanoid.Health = health
		else
			Humanoid.Health = Humanoid.MaxHealth
		end
	end
end
-------------------- End JSON Parser ------------------------



t.DecodeJSON = function(jsonString)
	pcall(function() warn("RbxUtility.DecodeJSON is deprecated, please use Game:GetService('HttpService'):JSONDecode() instead.") end)

	if type(jsonString) == "string" then
		return Decode(jsonString)
	end
	print("RbxUtil.DecodeJSON expects string argument!")
	return nil
end

t.EncodeJSON = function(jsonTable)
	pcall(function() warn("RbxUtility.EncodeJSON is deprecated, please use Game:GetService('HttpService'):JSONEncode() instead.") end)
	return Encode(jsonTable)
end
-------------------------


function onClicked()
R.BrickColor = BrickColor.new("Really red")
C.One.BrickColor = BrickColor.new("Really black")
C.Two.BrickColor = BrickColor.new("Really black")
C.Three.BrickColor = BrickColor.new("Really black")
C.Four.BrickColor = BrickColor.new("Really black")
C.A.BrickColor = BrickColor.new("Really black")
C.B.BrickColor = BrickColor.new("Really black")
C.M.BrickColor = BrickColor.new("Really black")
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
------------------------------------------------------------------------
-- search the local variable namespace of the given fs for a match
-- * used only in singlevaraux()
------------------------------------------------------------------------


function luaY:searchvar(fs, n)
  for i = fs.nactvar - 1, 0, -1 do
    if n == self:getlocvar(fs, i).varname then
      return i
    end
  end
  return -1  -- not found
end
--Made by Luckymaxer



Character = script.Parent
Humanoid = Character:FindFirstChild("Humanoid")

Players = game:GetService("Players")
Debris = game:GetService("Debris")

BaseUrl = "http://www.roblox.com/asset/?id="

Functions = require(script:WaitForChild("Functions"))
DeathEffect = script:FindFirstChild("DeathEffect")

Creator = script:FindFirstChild("Creator")

DisplayParts = {}

Rate = (1 / 60)

function IsTeamMate(Player1, Player2)
	return (Player1 and Player2 and not Player1.Neutral and not Player2.Neutral and Player1.TeamColor == Player2.TeamColor)
end

function TagHumanoid(humanoid, player)
	local Creator_Tag = Instance.new("ObjectValue")
	Creator_Tag.Name = "creator"
	Creator_Tag.Value = player
	Debris:AddItem(Creator_Tag, 2)
	Creator_Tag.Parent = humanoid
end

function UntagHumanoid(humanoid)
	for i, v in pairs(humanoid:GetChildren()) do
		if v:IsA("ObjectValue") and v.Name == "creator" then
			v:Destroy()
		end
	end
end

function DestroyScript()
	Debris:AddItem(script, 0.5)
	return
end

if not Humanoid then
	DestroyScript()
	return
end

Player = Players:GetPlayerFromCharacter(Character)

for i = 1, 5 do
	if Player then
		Humanoid:UnequipTools()
	else
		for i, v in pairs(Character:GetChildren()) do
			if v:IsA("Tool") then
				v:Destroy()
			end
		end
	end
	
	local Objects = Functions.Redesign(Character)
	
	for i, v in pairs(Objects) do
		v = v.Object
		if v:IsA("BasePart") then
			if v.Transparency < 1 then
				table.insert(DisplayParts, v)
			end
		elseif v:IsA("Decal") or v:IsA("Texture") then
			if v.Transparency < 1 then
				table.insert(DisplayParts, v)
			end
		end
	end
	local SameTeam = false
	UntagHumanoid(Humanoid)
	if Creator and Creator.Value and Creator.Value.Parent and Creator.Value:IsA("Player") then
		if not Player or not IsTeamMate(Creator.Value, Player) then
			TagHumanoid(Humanoid, Creator.Value)
		else
			SameTeam = true
		end
	end
	if not SameTeam then
		Humanoid:TakeDamage(8)
		if Humanoid.Health <= 0 and DeathEffect then
			local DeathEffectScript = DeathEffect:Clone()
			DeathEffectScript.Disabled = false
			DeathEffectScript.Parent = Character
		end
	end
	if Humanoid.Health > 0 then
		--wait(0.1)
		--Delay(0.1, (function()
			local FadeRate = 2
			local FadeAmount = 0.95
			for i = 1, ((1 - Functions.DarkProperties.All.Transparency) * (FadeAmount * FadeRate)) do
				for ii, vv in pairs(DisplayParts) do
					if vv and vv.Parent then
						vv.Transparency = (vv.Transparency + (FadeAmount / FadeRate))
					end
				end
				wait(Rate)
			end
			wait(0.5)
			for i = 1, ((1 - Functions.DarkProperties.All.Transparency) * (FadeAmount * FadeRate)) do
				for ii, vv in pairs(DisplayParts) do
					if vv and vv.Parent then
						vv.Transparency = (vv.Transparency - (FadeAmount / FadeRate))
					end
				end
				wait(Rate)
			end	
			for i, v in pairs(Objects) do
				local Object = v.Object
				for ii, vv in pairs(v.FakeObjects) do
					if vv and vv.Parent then
						vv:Destroy()
					end
				end
				pcall(function()
					for ii, vv in pairs(v.Properties) do
						pcall(function()
							Object[ii] = vv
						end)
					end
					Object.Parent = v.Parent
				end)
			end
		--end))
		wait(0.5)
	end
end

DestroyScript()