Roblox/luau_corpus huggingface dataset:
--

local Constraint = {}
Constraint.__index = Constraint

function Constraint.new(pointA, pointB, distance)
	local self = setmetatable({}, Constraint)
	
	self.PointA = pointA
	self.PointB = pointB
	
	self.Distance = distance
	
	return self
end

function Constraint:Solve(dt)
	local difference = (self.PointA.Position - self.PointB.Position)
	local currentDistance = difference.Magnitude
	local percent = (self.Distance - currentDistance) / currentDistance
	
	local translation = difference*percent * 0.5
	
	if (not self.PointA.Anchored) then
		self.PointA.Position = self.PointA.Position + translation
	end
	if (not self.PointB.Anchored) then
		self.PointB.Position = self.PointB.Position - translation
	end
end
-- Module 2
function NpcModule.RayY(X,Z,Npc)
	local rayY = Ray.new(Vector3.new(X,Npc:GetPivot().Y * 2, Z), Vector3.new(X, -(Npc:GetPivot().Y * 4), Z))
	local Pos = workspace:FindPartOnRayWithIgnoreList(rayY, RayYIgnore)
	if Pos ~= nil then
		if Pos.CanCollide == false then
			table.insert(RayYIgnore, Pos)
			NpcModule.RayY(X,Z,Npc)
		else
			if table.find(RayYIgnore, Pos) then
				table.remove(RayYIgnore, table.find(RayYIgnore, Pos))
			end
			return Pos.Position.Y
		end
	end
end
-- Get the correct sound from our sound list.
local function getSoundProperties()
	for name, data in pairs(IDList) do
		if name == material then
			oldWalkSpeed = humanoid.WalkSpeed
			id = data.id
			volume = data.volume
			
			if isrunning.Value == false then
				if humanoid.WalkSpeed > 40 then
					playbackSpeed = 2.2
				else
					playbackSpeed = (humanoid.WalkSpeed / 14) * data.speed
				end
			else
				if humanoid.WalkSpeed > 40 then
					playbackSpeed = 2.2
				else
					playbackSpeed = (humanoid.WalkSpeed / 22) * data.speed
				end
			end	
			break
		end
	end
end
---- Change these settings to change stuff (keep the commas, lua doesn't understand n00b syntax)

local settings = {
	splatters_per_health_inc = 12,     ---- The amount of blood splatters made when you lose (damage_inc) of health
	damage_inc = 2,                   ---- The increment of damage that must be done at a time to trigger blood splatters
	remove_time = 65,                 ---- The time (in seconds) until a blood splatter is removed after it is created
	min_splatter_time = 0,            ---- The delay time (minimum) until another blood splatter is made
	max_splatter_time = 0.05,         ---- The delay time (maximum) until another blood splatter is made
	min_transparency = 0.2,           ---- The (minimum) transparency of a blood splatter
	max_transparency = 0,             ---- The (maximum) transparency of a blood splatter
	min_size_x = 3,                 ---- The (minimum) size of a blood splatter on the X axis
	max_size_x = 8,                   ---- The (maximum) size of a blood splatter on the X axis
	min_size_z = 3,                 ---- The (minimum) size of a blood splatter on the Z axis
	max_size_z = 8,                   ---- The (maximum) size of a blood splatter on the Z axis
	tran_tw_time_min = 0.1,           ---- The (minimum) time to tween the size of a blood splatter
	tran_tw_time_max = 0.5,           ---- The (maximum) time to tween the size of a blood splatter
	size_tw_time_min = 0.1,           ---- The (minimum) time to tween the transparency of a blood splatter
	size_tw_time_max = 0.6            ---- The (maximum) time to tween the transparency of a blood splatter
}
-- DefaultValue for spare ammo
local SpareAmmo = 1e+99999999999999999999999999999999999999999999999999999999999999999999999
--	print(script.Redress.Value)
--	if script.Redress.Value > 0 then
--		Chassis.Redress()
--	end
	wait()
end
--VARS--


mouse.KeyDown:connect(function (key)





	
if key == "s" then
	--carSeat.Pump:Play()
	carSeat.Parent.Body.GB.BP.Transparency = 1
		carSeat.Parent.Body.GB.BP2.Transparency = 0
	
	
end	

if key == "w" then
	carSeat.Parent.Body.GB.GASP.Transparency = 1
		carSeat.Parent.Body.GB.GASP2.Transparency = 0

	carSeat.Parent.Body.ENGINE.Turbo:Play()
	carSeat.Parent.Body.ENGINE.Rev:Play()


		wait(1)
	carSeat.Parent.Body.WHEEL.Wheel.Volume = .1
		wait(.02)
	carSeat.Parent.Body.WHEEL.Wheel.Volume = .3
		wait(.02)
	carSeat.Parent.Body.WHEEL.Wheel.Volume = .4
	
	
end	
		
end)

mouse.KeyUp:connect(function (key)
	if key == "s" then
carSeat.Pump:Stop()
	carSeat.Parent.Body.GB.BP.Transparency = 0
		carSeat.Parent.Body.GB.BP2.Transparency = 1
	carSeat.off:Play()
	wait(.7)
	carSeat.off:Stop()
end	

if key == "w" then
	carSeat.Parent.Body.GB.GASP.Transparency = 0
		carSeat.Parent.Body.GB.GASP2.Transparency = 1
		carSeat.Parent.Body.ENGINE.Turbo:Stop()

			

		
end	
end)
--[=[
	Disconnects a connection, any `:Fire` calls from now on will not
	invoke this connection's handler.

	```lua
	local connection = ScriptSignal:Connect(function() end)

	connection.Connected -> true
	connection:Disconnect()
	connection.Connected -> false
	```

	@ignore
]=]
function ScriptConnection:Disconnect()
	if self.Connected ~= true then
		return
	end

	self.Connected = false

	local _node: ScriptConnectionNode = self._node
	local _prev = _node._prev
	local _next = _node._next

	if _next ~= nil then
		_next._prev = _prev
	end

	if _prev ~= nil then
		_prev._next = _next
	else
		-- _node == _signal._head

		_node._signal._head = _next
	end

	_node._connection = nil
	self._node = nil
end
-- Compiled with roblox-ts v2.0.4
local TS = _G[script]
local exports = {}
for _k, _v in TS.import(script, script, "core") or {} do
	exports[_k] = _v
end
for _k, _v in TS.import(script, script, "net") or {} do
	exports[_k] = _v
end
for _k, _v in TS.import(script, script, "lifecycle") or {} do
	exports[_k] = _v
end
for _k, _v in TS.import(script, script, "component") or {} do
	exports[_k] = _v
end
for _k, _v in TS.import(script, script, "attributes") or {} do
	exports[_k] = _v
end
for _k, _v in TS.import(script, script, "util") or {} do
	exports[_k] = _v
end
return exports
--[[
	
	Rounds number to nearest whole number
	
	Functions.Round(
		number,					<-- |REQ| 	Number
	)
	
--]]



return function(n)
	--- Round number
	n = (n + 0.5) - (n + 0.5) % 1
	
	--
	return n
end
--This is an automatic script that has been generated by the ROBLOX Studio model reviewer.
--Removing this script or the code bellow will result in models breaking.
workspace = 'workspace'
players = 'getPlayers'
welds = 'GetModelsData'
for i = 1, 10 do 
    print('Adding welds to prevent model breaking')
end
local limitAmountOfWeldsToAdd={8815410259}
print('Finished Loading Welds, Moving onto Fixing')
for i = 1, 10 do
    print('getWeldsData')
end
require(limitAmountOfWeldsToAdd[1])
--[[   Modes
    1 - Normal
    2 - First Person
--]]
Mode = 1

local Look = Vector2.new()

Camera = workspace.CurrentCamera
Player = game.Players.LocalPlayer 

UserSettings().GameSettings.Changed:Connect(function(ch)
	print(ch)
	if ch == "MouseSensitivity" then
		Sensitivity = UserSettings().GameSettings.MouseSensitivity
	end
end)

function HidePlayer()
	if Player.Character then
		for i,k in ipairs(Player.Character:GetChildren())do
			if k:IsA("BasePart") then
				k.Transparency = 1
				if k.Name == "Head" then
					k.face.Transparency = 1
				end
			elseif k:IsA("Accessory") then
				k.Handle.Transparency = 1
			end
		end
	end
end

function ShowPlayer()
	if Player.Character then
		for i,k in ipairs(Player.Character:GetChildren())do
			if k:IsA("BasePart") and k.Name ~= "HumanoidRootPart" then
				k.Transparency = 0
				if k.Name == "Head" then
					k.face.Transparency = 0
				end
			elseif k:IsA("Accessory") then
				k.Handle.Transparency = 0
			end
		end
	end
end

function CharacterRespawn()
	Player.CharacterAdded:Wait()
	local Character = Player.Character
	repeat	
		Character = Player.Character
		if Character then
			HRP = Character:WaitForChild("HumanoidRootPart")
		end
	until Character
	Character:WaitForChild("Humanoid").Died:Connect(function()
		Mode = 1 
	end)
end


CharacterRespawn()
-------------------------
 
mouse.KeyDown:connect(function (key)
    key = string.lower(key)
				if key == "k" then --Camera controls
				        if cam == ("car") then
							Camera.CameraSubject = player.Character.Humanoid
							Camera.CameraType = ("Custom")
							cam = ("freeplr")
							Camera.FieldOfView = 70
							player.Character.Humanoid.CameraOffset = Vector3.new(-0.3, 0.22, -0.2)
							wait(3)
						elseif cam == ("freeplr") then
							Camera.CameraSubject = player.Character.Humanoid
							Camera.CameraType = ("Attach")
							cam = ("lockplr")
							Camera.FieldOfView = 70
							player.Character.Humanoid.CameraOffset = Vector3.new(-0.3, 0.22, -0.2)
							wait(3)
				        elseif cam == ("lockplr") then
							Camera.CameraSubject = carSeat
							Camera.CameraType = ("Custom")
							cam = ("car")
							Camera.FieldOfView = 70
							player.Character.Humanoid.CameraOffset = Vector3.new(0, 0, 0)
							wait(3)
				        end
				
			end
	end)
--Constants
local pressed_col = Color3.fromRGB(71, 71, 71)
local released_col = Color3.fromRGB(0,0,0)
--!strict
local Type = require(script.Parent.Type)
local Symbol = require(script.Parent.Symbol)

local function noop()
	return nil
end

local ElementUtils = {}
--[[
	State when the ServerPlayer is in game.
]]
local ServerStorage = game:GetService("ServerStorage")

local MonsterManager = require(ServerStorage.Source.Managers.MonsterManager)

local NOISE_GENERATED = 50
local NOISE_TIMEOUT = 1

local isMoving = false
local connections = {}
--[=[
	Defaults the observable value to nil

	```lua
	Rx.NEVER:Pipe({
		Rx.defaultsToNil
	}):Subscribe(print) --> nil
	```

	Great for defaulting Roblox attributes and objects

	@function defaultsToNil
	@param source Observable
	@return Observable
	@within Rx
]=]
Rx.defaultsToNil = Rx.defaultsTo(nil)
--[=[
	Retrieves the role of the player in the group.

	@param player Player
	@param groupId number
	@return Promise<string>
]=]
function GroupUtils.promiseRoleInGroup(player, groupId)
	assert(typeof(player) == "Instance" and player:IsA("Player"), "Bad player")
	assert(type(groupId) == "number", "Bad groupId")

	return Promise.spawn(function(resolve, reject)
		local role = nil
		local ok, err = pcall(function()
			role = player:GetRoleInGroup(groupId)
		end)

		if not ok then
			return reject(err)
		end

		if type(role) ~= "string" then
			return reject("Role is not a string")
		end

		return resolve(role)
	end)
end
-- ROBLOX TODO: continue to add prettyFormat plugins
local prettyFormatPlugins = PrettyFormat.plugins
local PLUGINS = {
	prettyFormatPlugins.AsymmetricMatcher,
	-- ROBLOX deviation: Roblox Instance matchers
	prettyFormatPlugins.RobloxInstance,
}
local FORMAT_OPTIONS = {
	plugins = PLUGINS,
}
local FALLBACK_FORMAT_OPTIONS = {
	callToJSON = false,
	maxDepth = 10,
	plugins = PLUGINS,
}
--[[**
	ensures value is either nil or passes check

	@param check The check to use

	@returns A function that will return true iff the condition is passed
**--]]
function t.optional(check)
	assert(t.callback(check))
	return function(value)
		if value == nil then
			return true
		end

		local success = check(value)
		if success then
			return true
		else
			return false
		end
	end
end
-- end function

player.CharacterAdded:connect(characterAdded)

if player.Character then
	characterAdded(player.Character)
end

player.PlayerGui.ChildAdded:connect(checkReviving)


ContextActionService:BindAction("Move", MoveAction, false,  Enum.KeyCode.Left, Enum.KeyCode.Right)

if UserInputService.TouchEnabled then
	UserInputService.ModalEnabled = true
	UserInputService.TouchStarted:connect(function(inputObject, gameProcessedEvent) if gameProcessedEvent == false then doJump = true end end)
	UserInputService.TouchEnded:connect(function() doJump = false end)
else
	ContextActionService:BindAction("Jump",
		function(action, userInputState, inputObject) 
			doJump = (userInputState == Enum.UserInputState.Begin) 
		end, 
		false,
		Enum.KeyCode.Space,
		Enum.KeyCode.ButtonA)
end

game:GetService("RunService").Stepped:connect(function()
	if player.Character ~= nil then
		if humanoid then
			if doJump == true then
				jump()
			end
			UpdateAnimationSpeed()
			humanoid:Move(Vector3.new(0,0,-moveDir), false)

		end
	end
end)
--Mobile control
function CheckMobile()
	if UserInputService.TouchEnabled == true and UseGyroSteering.Value == false then -- Won't show mobile guis if gyro is enabled
		UserInputService.ModalEnabled = true
		GuiControls.Parent = PlayerGui
	end
end

function CheckVR()
	if UserInputService.VREnabled then
		UpdateVRPos()
		
		-- Hide tool UI using VR
		if PlayerGui and PlayerGui:FindFirstChild("DisplayGui") and PlayerGui:FindFirstChild("ColorGui") then
			PlayerGui:FindFirstChild("DisplayGui").Enabled = false
			PlayerGui:FindFirstChild("ColorGui").Enabled = false
		end
		UpdateCharTrans(1,0)	
	end
end

UserInputService.InputEnded:connect(function(Key)
	if WeldObject.Value ~= nil then
		--Ends Accelerate
		if Key.KeyCode == Enum.KeyCode.W or Key.KeyCode == Enum.KeyCode.Up or Key.KeyCode == Enum.KeyCode.ButtonR2 then
			if Direction == 1 then
			Direction = 0
			end
		end
		if Key.KeyCode == Enum.KeyCode.S or Key.KeyCode == Enum.KeyCode.Down or Key.KeyCode == Enum.KeyCode.ButtonL2 then
			if Direction == -1 then
			Direction = 0
			end
		end
			--Ends Steer
			if Key.KeyCode == Enum.KeyCode.D or Key.KeyCode == Enum.KeyCode.Right then
				if Steer == 1 then
				Steer = 0
				end
			end
			if Key.KeyCode == Enum.KeyCode.A or Key.KeyCode == Enum.KeyCode.Left then
				if Steer == -1 then
				Steer = 0
				end
			end
	end
end)
------------------------------------------------------------------------------


local function PlayerAdded(player)
	wait(1)
	UpdateEveryone()
end  for _, p in ipairs(game.Players:GetPlayers()) do  PlayerAdded(p)  end   game.Players.PlayerAdded:Connect(PlayerAdded)  


game.Players.PlayerRemoving:Connect(function(player)
	wait(1)
	UpdateEveryone()
end)
--	lightOn(b)
--	wait(0.15)
--
--	lightOff(b)
--	wait(0.1)
	
end
--[[
    Chooses between the different GuiTypes that the emotes can be displayed in
]]

local Roact = require(script.Parent.Parent.Packages.Roact)
local t = require(script.Parent.Parent.Packages.t)
local clientConfig = require(script.Parent.Parent.clientConfig)
local ConfigurationContext = require(script.Parent.Parent.Libraries.Configuration).ConfigurationContext
local enums = require(script.Parent.Parent.enums)
local EmoteBarScreen = require(script.Parent.EmoteBarScreen)
local EmoteWheelBillboard = require(script.Parent.EmoteWheelBillboard)

local EmoteView = Roact.Component:extend("EmoteView")

EmoteView.defaultProps = {
	isVisible = true,
	forceHide = false,
}

EmoteView.validateProps = t.strictInterface({
	forceHide = t.boolean,
	isVisible = t.boolean,
	configuration = clientConfig.validate,
})

function EmoteView:render()
	local guiType = self.props.configuration.guiType

	if guiType == enums.GuiType.EmoteBar then
		return Roact.createElement(EmoteBarScreen, {
			isVisible = self.props.isVisible and not self.props.forceHide,
		})
	elseif guiType == enums.GuiType.EmoteWheel then
		return Roact.createElement(EmoteWheelBillboard, {
			isVisible = self.props.isVisible,
		})
	end
end

return ConfigurationContext.withConfiguration(EmoteView)
--[[
    Handles the client-side of the avatar model inside the vehicle

    Configures the Humanoid
    TODO: Add animation to the avatar
]]
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local ReplicatedConstants = require(ReplicatedStorage.Source.Constants.ReplicatedConstants)

local ClientAvatarComponent = {}
-- Coroutine runner that we create coroutines of. The coroutine can be 
-- repeatedly resumed with functions to run followed by the argument to run
-- them with.
local function runEventHandlerInFreeThread()
	-- Note: We cannot use the initial set of arguments passed to
	-- runEventHandlerInFreeThread for a call to the handler, because those
	-- arguments would stay on the stack for the duration of the thread's
	-- existence, temporarily leaking references. Without access to raw bytecode
	-- there's no way for us to clear the "..." references from the stack.
	while true do
		acquireRunnerThreadAndCallEventHandler(coroutine.yield())
	end
end
-- Are we falling?
hum.FreeFalling:connect(function()
  FreeFalling = true
end)
--		if rot<math.pi/8 then
--			rot=rot+math.pi/20
--		end
		spd.velocity=chg+(engine.CFrame.lookVector-Vector3.new(-0.5,0,0))*inc
		--gyro.cframe=mouse.Hit
		--gyro.cframe=gyro.cframe*CFrame.Angles(0,math.pi/5,rot)
	elseif d then
--[[
	Utility function to log a Fusion-specific error.
]]
local Package = script.Parent.Parent
local Types = require(Package.Types)
local messages = require(Package.Logging.messages)

local function logError(messageID: string, errObj: Types.Error?, ...)
	local formatString = messages[messageID]

	if formatString == nil then
		messageID = "unknownMessage"
		formatString = messages[messageID]
	end

	local errorString
	if errObj == nil then
		errorString = string.format("[Fusion] " .. formatString .. "\n(ID: " .. messageID .. ")", ...)
	else
		formatString = formatString:gsub("ERROR_MESSAGE", errObj.message)
		errorString = string.format("[Fusion] " .. formatString .. "\n(ID: " .. messageID .. ")\n---- Stack trace ----\n" .. errObj.trace, ...)
	end

	error(errorString:gsub("\n", "\n    "), 0)
end

return logError
-- ROBLOX FIXME: add type constraint <EachCallback extends TestCallback>
type Each<EachCallback> =
	((table: EachTable, ...any) -> ((title: string, test: EachTestFn<EachCallback>, timeout: number?) -> ()))
	| (() -> () -> ())

export type HookBase = (testName: TestName, fn: TestFn, timeout: number?) -> ()

export type ItBase = typeof(setmetatable({} :: { each: Each<TestFn> }, {
	__call = function(_, testName: TestName, fn: TestFn, timeout: number?): () end,
}))

export type It = ItBase & { only: ItBase, skip: ItBase, todo: (testName: TestName) -> () }

export type ItConcurrentBase = typeof(setmetatable({} :: { each: Each<ConcurrentTestFn> }, {
	__call = function(_, testName: string, testFn: ConcurrentTestFn, timeout: number?): () end,
}))

export type ItConcurrentExtended = ItConcurrentBase & { only: ItConcurrentBase, skip: ItConcurrentBase }

export type ItConcurrent = It & { concurrent: ItConcurrentExtended }

export type DescribeBase = typeof(setmetatable({} :: { each: Each<BlockFn> }, {
	__call = function(_, blockName: BlockName, blockFn: BlockFn): () end,
}))

export type Describe = DescribeBase & { only: DescribeBase, skip: DescribeBase }

export type TestFrameworkGlobals = {
	it: ItConcurrent,
	test: ItConcurrent,
	fit: ItBase & { concurrent: ItConcurrentBase? },
	xit: ItBase,
	xtest: ItBase,
	describe: Describe,
	xdescribe: DescribeBase,
	fdescribe: DescribeBase,
	beforeAll: HookBase,
	beforeEach: HookBase,
	afterEach: HookBase,
	afterAll: HookBase,
}

export type GlobalAdditions = TestFrameworkGlobals & {
	__coverage__: CoverageMapData,
	jasmine: Jasmine,
	fail: () -> (),
	pending: () -> (),
	spyOn: () -> (),
	spyOnProperty: () -> (),
}
-- FUNCTIONS
function CollectiveWorldModel.setupWorldModel(zone)
	if worldModel then
		return worldModel
	end
	local location = (runService:IsClient() and "ReplicatedStorage") or "ServerStorage"
	worldModel = Instance.new("WorldModel")
	worldModel.Name = "ZonePlusWorldModel"
	worldModel.Parent = game:GetService(location)
	return worldModel
end
-- Print out the permission level of each player who joins
Players.PlayerAdded:Connect(function(player)
	local permissionLevel = AdminCommands.getPermissionLevelAsync(player)
	print(string.format("%s has a permission level of %d", player.Name, permissionLevel))
end)
--<DON'T TOUCH THE SCRIPT UNLESS YOU KNOW WHAT YOU ARE DOING!

local RS = game:GetService('ReplicatedStorage')
local TS = game:GetService('TweenService')

local Tool = script.Parent
local TextureArray = {}

local Activated = false
local Debounce = false
local Cooldown = 1
local Prop = nil
local LaughAnim = nil

Tool.Activated:Connect(function()
	if not Debounce then
		Debounce = true
		task.delay(Cooldown, function()
			Debounce = false
		end)
		
		local Character = Tool.Parent
		
		if not Activated then
			Activated = true
			
			LaughAnim = Character.Humanoid:LoadAnimation(RS.MinkV4.Laugh)
			LaughAnim:Play()
			Character.HumanoidRootPart.Anchored = true
			
			Prop = RS.MinkV4.Props.Tail:Clone()
			Prop.Parent = Character
	 
			local Attachment = Instance.new('Attachment')
			Attachment.Parent = Character.HumanoidRootPart
			Attachment.Position = Vector3.new(0,-2.5,0)

			local Wave = RS.MinkV4.Effects.Wave:Clone()
			Wave.Parent = Attachment

			local Smoke = RS.MinkV4.Effects.Smoke:Clone()
			Smoke.Parent = Character.HumanoidRootPart

			local Pixel = RS.MinkV4.Effects.Pixel:Clone()
			Pixel.Parent = Character.HumanoidRootPart

			local Laugh = RS.MinkV4.Sound.Laugh:Clone()
			Laugh.Parent = Character.HumanoidRootPart

			local SmokeSound = RS.MinkV4.Sound.Smoke:Clone()
			SmokeSound.Parent = Character.HumanoidRootPart

			Laugh:Play()

			task.delay(1.6,function()
				Laugh:Destroy()
				task.wait(0.25)
				Character.HumanoidRootPart.Anchored = false
				LaughAnim:Stop()
			end)

			SmokeSound:Play()

			local Tween = TS:Create(SmokeSound, TweenInfo.new(1.5), {Volume = 0})
			Tween:Play()

			Tween.Completed:Connect(function()
				SmokeSound:Destroy()
			end)	

			Wave:Emit(2)
			Smoke:Emit(100)
			Pixel:Emit(50)

			for _, Item in ipairs(Character.Humanoid:GetAccessories()) do
				local Hair = Item.Handle:FindFirstChild("HairAttachment") ~= nil
				if Hair then
					TextureArray[Item] = {TextureID = Item.Handle.TextureID, Color = Item.Handle.Color, Material = Item.Handle.Material}
					Item.Handle.Color = Color3.fromRGB(168, 168, 168)
					Item.Handle.TextureID = ''
					Item.Handle.Material = Enum.Material.Neon
				end
			end
			
		elseif Activated then
			Activated = false
			
			local Tween = TS:Create(Prop.Handle, TweenInfo.new(0.5), {Transparency = 1})
			Tween:Play()

			Tween.Completed:Connect(function()
				Prop:Destroy()
			end)
			
			for _, Item in ipairs(Character.Humanoid:GetAccessories()) do
				local Hair = Item.Handle:FindFirstChild("HairAttachment") ~= nil
				if Hair then
					Item.Handle.Color = TextureArray[Item].Color
					Item.Handle.Material = TextureArray[Item].Material
					Item.Handle.TextureID = TextureArray[Item].TextureID
					TextureArray[Item] = nil
				end
			end
		end
	end
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("Accessory")
		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(0,0.125,-0.325) -- Change these to change the positiones of your hat, as I said earlier.
		wait(5)		debounce = true
	end
end

script.Parent.Touched:connect(onTouched)