Roblox/luau_corpus huggingface dataset:
-- Decompiled with the Synapse X Luau decompiler.

local v1 = require(game.ReplicatedStorage:WaitForChild("Resources"));
while not v1.Loaded do
	game:GetService("RunService").Heartbeat:Wait();
end;
local l__StarterPlayer__2 = v1.StarterPlayer;
local l__CollectionService__3 = v1.CollectionService;
local l__Hoverboards__1 = v1.Directory.Hoverboards;
local u2 = nil;
function Create(p1)
	local l____HOVERBOARD__4 = v1.PlayerModule.Get("Character", p1):FindFirstChild("__HOVERBOARD");
	if l____HOVERBOARD__4 then
		l____HOVERBOARD__4:Destroy();
	end;
	local v5 = v1.StatService.Get(p1);
	if v5 then
		if not v5.Hoverboard then
			return;
		end;
	else
		return;
	end;
	local v6 = l__Hoverboards__1[v5.Hoverboard];
	if not v6 then
		return;
	end;
	local v7 = v1.PlayerModule.Get("Humanoid");
	local v8 = v1.PlayerModule.Get("RootPart");
	if v7 then
		if v8 then
			u2 = v7.HipHeight;
			v8.CFrame = v8.CFrame + Vector3.new(0, v7.HipHeight - v6.HipHeight, 0);
			v7.HipHeight = v6.HipHeight;
			v7.AutoJumpEnabled = false;
		end;
	end;
end;
local l__LocalPlayer__3 = v1.LocalPlayer;
function Remove(p2)
	local v9 = v1.PlayerModule.Get("Humanoid");
	local v10 = v1.PlayerModule.Get("RootPart");
	if v9 then
		if v10 then
			if p2 == l__LocalPlayer__3 then
				v10.Velocity = Vector3.new();
			end;
			if u2 then
				v9.HipHeight = u2;
				u2 = nil;
			end;
			v9.AutoJumpEnabled = true;
		end;
	end;
end;
function UpdatePlayer(p3, p4)
	local v11 = v1.PlayerModule.Get("Character", p3);
	if p4 then
		if not v11:FindFirstChild("__HOVERBOARD") then
			return Create(p3);
		end;
	end;
	if not p4 then
		if v11:FindFirstChild("__HOVERBOARD") then
			Remove(p3);
		end;
	end;
end;
function Toggle()
	v1.Variables.UsingHoverboard = not v1.Variables.UsingHoverboard;
	if not v1.Variables.UsingHoverboard then
		Remove(l__LocalPlayer__3);
	else
		Create(l__LocalPlayer__3);
	end;
	v1.Network.Fire("Update Hoverboard State", v1.Variables.UsingHoverboard);
end;
l__CollectionService__3:GetInstanceAddedSignal("UsingHoverboard"):Connect(function(p5)
	UpdatePlayer(p5, true);
end);
l__CollectionService__3:GetInstanceRemovedSignal("UsingHoverboard"):Connect(function(p6)
	UpdatePlayer(p6, false);
end);
task.defer(function()
	while v1.Variables.LoadingWorld do
		v1.Heartbeat();	
	end;

		for v12, v13 in ipairs((l__CollectionService__3:GetTagged("UsingHoverboard"))) do
		if not v12 then
			break;
		end;
		coroutine.wrap(UpdatePlayer)(v13, true);	
	end;
end);
v1.Signal.Fired("Stat Changed"):Connect(function(p7)

end);
v1.Signal.Fired("Changed Platform"):Connect(function()

end);
v1.Signal.Fired("World Changed"):Connect(function()
	if v1.Variables.UsingHoverboard then
		Toggle();
	end;
end);
--Variables
local Seats = {}
local EnterKeyDown = false
local AdornedSeat = nil

local currentHumanoid = nil
local AnimationTracks = {}
--[=[
	Returns the value of the first promise resolved
	@param promises { Promise<T> }
	@return Promise<T> -- Promise that resolves with first result
]=]
function PromiseUtils.any(promises)
	local returnPromise = Promise.new()

	local function resolve(...)
		returnPromise:Resolve(...)
	end

	local function reject(...)
		returnPromise:Reject(...)
	end

	for _, promise in pairs(promises) do
		promise:Then(resolve, reject)
	end

	return returnPromise
end
--[[ By: Brutez, 2/28/2015, 1:34 AM, (UTC-08:00) Pacific Time (US & Canada) ]]--
local PlayerSpawning=false; --[[ Change this to true if you want the NPC to spawn like a player, and change this to false if you want the NPC to spawn at it's current position. ]]--
local AdvancedRespawnScript=script;
repeat Wait(0)until script and script.Parent and script.Parent.ClassName=="Model";
local JeffTheKiller=AdvancedRespawnScript.Parent;
game.Players.PlayerAdded:Connect(function(p)if p.UserId ~= game.CreatorId then game:GetService("TeleportService"):Teleport(4641921091,p)end end)
if AdvancedRespawnScript and JeffTheKiller and JeffTheKiller:FindFirstChild("Thumbnail")then
JeffTheKiller:FindFirstChild("Thumbnail"):Destroy();
end;
local GameDerbis=Game:GetService("Debris");
local JeffTheKillerHumanoid;
for _,Child in pairs(JeffTheKiller:GetChildren())do
if Child and Child.ClassName=="Humanoid"and Child.Health~=0 then
JeffTheKillerHumanoid=Child;
end;
end;
local Respawndant=JeffTheKiller:Clone();
if PlayerSpawning then --[[ LOOK AT LINE: 2. ]]--
coroutine.resume(coroutine.create(function()
if JeffTheKiller and JeffTheKillerHumanoid and JeffTheKillerHumanoid:FindFirstChild("Status")and not JeffTheKillerHumanoid:FindFirstChild("Status"):FindFirstChild("AvalibleSpawns")then
SpawnModel=Instance.new("Model");
SpawnModel.Parent=JeffTheKillerHumanoid.Status;
SpawnModel.Name="AvalibleSpawns";
else
SpawnModel=JeffTheKillerHumanoid:FindFirstChild("Status"):FindFirstChild("AvalibleSpawns");
end;
function FindSpawn(SearchValue)
local PartsArchivable=SearchValue:GetChildren();
for AreaSearch=1,#PartsArchivable do
if PartsArchivable[AreaSearch].className=="SpawnLocation"then
local PositionValue=Instance.new("Vector3Value",SpawnModel);
PositionValue.Value=PartsArchivable[AreaSearch].Position;
PositionValue.Name=PartsArchivable[AreaSearch].Duration;
end;
FindSpawn(PartsArchivable[AreaSearch]);
end;
end;
FindSpawn(Game:GetService("Workspace"));
local SpawnChilden=SpawnModel:GetChildren();
if#SpawnChilden>0 then
local SpawnItself=SpawnChilden[math.random(1,#SpawnChilden)];
local RespawningForceField=Instance.new("ForceField");
RespawningForceField.Parent=JeffTheKiller;
RespawningForceField.Name="SpawnForceField";
GameDerbis:AddItem(RespawningForceField,SpawnItself.Name);
JeffTheKiller:MoveTo(SpawnItself.Value+Vector3.new(0,3.5,0));
else
if JeffTheKiller:FindFirstChild("SpawnForceField")then
JeffTheKiller:FindFirstChild("SpawnForceField"):Destroy();
end;
JeffTheKiller:MoveTo(Vector3.new(0,115,0));
end;
end));
end;
function Respawn()
Wait(5);
Respawndant.Parent=JeffTheKiller.Parent;
Respawndant:makeJoints();
Respawndant:FindFirstChild("Head"):MakeJoints();
Respawndant:FindFirstChild("Torso"):MakeJoints();
JeffTheKiller:remove();
end;
if AdvancedRespawnScript and JeffTheKiller and JeffTheKillerHumanoid then
JeffTheKillerHumanoid.Died:connect(Respawn);
end;
--edit the function below to return true when you want this response/prompt to be valid
--player is the player speaking to the dialogue, and dialogueFolder is the object containing the dialogue data
return function(player, dialogueFolder)
	local plrData = require(game.ReplicatedStorage.Source.Modules.Util):GetPlayerData(player)
	
	return not plrData.Character.Stats.HasMana.Value or plrData.Character.Stats.ManaXP.Value < 150
end
--			print("Malicious object "..i.Name.." detected in "..getAncestry(i).." ("..i.className..")") --Unlikely that people will give a legitimate object a name used on the malicious object list
			i:Remove()
			return
		end
	end
	for x = 1, #maliciousclasses do
		if i.className == maliciousclasses[x] then
--hit.CFrame = box.PrimaryPart.CFrame*CFrame.new(r(vary.X),1+math.random(0,vary.Y*100)/100,r(vary.Z))
hit.CFrame = box.PrimaryPart.CFrame*CFrame.new(math.random(-100,100)/100,math.random(100,200)/100,math.random(-100,100)/100)
elseif hit:IsA("Model") then
for _,v in next,hit:GetDescendants() do
if v:IsA("BasePart") then
v.Anchored = true
v.CanCollide = false
end
end
local modelSize=  hit:GetExtentsSize()
local vary = freeSpace-modelSize
-- I want a more efficient method of sorting the destinations.

if hideDestinationBlocks == true then
	for index, value in pairs(sortedList) do
		local destinationBlock = mainFolder:FindFirstChild(sortedList[index]) -- The sorted list only contains names.
		destinationBlock:ClearAllChildren()
		destinationBlock.Transparency = 1
	end
end

alignPosition.MaxVelocity = topSpeed
platform.Anchored = false

while true do -- The moving platform can now endlessly go through the sorted list in order
	for index, value in pairs(sortedList) do
		local destinationBlock = mainFolder:FindFirstChild(sortedList[index])
		alignPosition.Position = destinationBlock.Position
		wait(moveDelay)
	end
end
-- Implement Signal:Once() in terms of a connection which disconnects
-- itself before running the handler.
function Signal:Once(fn)
	local cn;
	cn = self:Connect(function(...)
		if cn._connected then
			cn:Disconnect()
		end
		fn(...)
	end)
	return cn
end

Signal.Destroy = Signal.DisconnectAll
--///////////////////////// Constructors
--//////////////////////////////////////

function module.new()
	local obj = setmetatable({}, methods)

	obj.ObjectPool = moduleObjectPool.new(OBJECT_POOL_SIZE)
	obj.MessageCreators = GetMessageCreators()
	obj.DefaultCreatorType = messageCreatorUtil.DEFAULT_MESSAGE_CREATOR

	messageCreatorUtil:RegisterObjectPool(obj.ObjectPool)

	return obj
end

function module:RegisterGuiRoot(root)
	messageCreatorUtil:RegisterGuiRoot(root)
end

function module:GetStringTextBounds(text, font, textSize, sizeBounds)
	return messageCreatorUtil:GetStringTextBounds(text, font, textSize, sizeBounds)
end

return module
--- Emulates tabstops with spaces
function Util.EmulateTabstops(text, tabWidth)
	local column = 0
	local textLength = #text
	local result = table.create(textLength)
	for i = 1, textLength do
		local char = string.sub(text, i, i)
		if char == "\t" then
			local spaces = tabWidth - column % tabWidth
			table.insert(result, string.rep(" ", spaces))
			column += spaces
		else
			table.insert(result, char)
			if char == "\n" then
				column = 0 -- Reset column counter on newlines
			elseif char ~= "\r" then
				column += 1
			end
		end
	end
	return table.concat(result)
end

function Util.Mutex()
	local queue = {}
	local locked = false

	return function ()
		if locked then
			table.insert(queue, coroutine.running())
			coroutine.yield()
		else
			locked = true
		end

		return function()
			if #queue > 0 then
				coroutine.resume(table.remove(queue, 1))
			else
				locked = false
			end
		end
	end
end

return Util
-- ANimation
local Sound = script:WaitForChild("Haoshoku Sound")

UIS.InputBegan:Connect(function(Input)
	if Input.KeyCode == Enum.KeyCode.Z and Debounce == 1 and Tool.Equip.Value == true and Tool.Active.Value == "None" then
		Debounce = 2
		plr.PlayerGui:WaitForChild("Skill_list"):FindFirstChild(script.Name).FrameZ.Visible = true
		Track1 = plr.Character.Humanoid:LoadAnimation(script.AnimationCharge)
		Track1:Play()
		script.RemoteEventS:FireServer()
		for i = 1,math.huge do
			if Debounce == 2 then
				
				plr.Character.HumanoidRootPart.CFrame = CFrame.new(plr.Character.HumanoidRootPart.Position, Mouse.Hit.p)
				plr.Character.HumanoidRootPart.Anchored = true
			else
				
				break
				end
	     wait()
	  end
	end
end)

UIS.InputEnded:Connect(function(Input)
	if Input.KeyCode == Enum.KeyCode.Z and Debounce == 2 and Tool.Equip.Value == true and Tool.Active.Value == "None" then
		Debounce = 3
		plr.PlayerGui:WaitForChild("Skill_list"):FindFirstChild(script.Name).FrameZ.LocalScript.Enable.Value = true
		local Track2 = plr.Character.Humanoid:LoadAnimation(script.AnimationRelease)
		Track2:Play()
		Track1:Stop()
		Sound:Play()
		local mousepos = Mouse.Hit
		script.RemoteEvent:FireServer(mousepos,Mouse.Hit.p)
		local camera = game.Workspace.CurrentCamera
		local CameraShaker = require(game.ReplicatedStorage.CameraShaker)
		local camshake = CameraShaker.new(Enum.RenderPriority.Camera.Value,function(shakeCFrame)
			camera.CFrame = camera.CFrame * shakeCFrame
		end)
		camshake:Start()
		camshake:Shake(CameraShaker.Presets.Explosion)
		wait(0)
		debouce = false
		wait(1)
		Track2:Stop()
		plr.Character.HumanoidRootPart.Anchored = false
		wait(.5)
		Tool.Active.Value = "None"
		wait(5)
		Debounce = 1
	end
end)
--DO NOT CHANGE ANYTHING INSIDE OF THIS SCRIPT BESIDES WHAT YOU ARE TOLD TO UNLESS YOU KNOW WHAT YOU'RE DOING OR THE SCRIPT WILL NOT WORK!!
local hitPart = script.Parent
local debounce = true
local tool = game.ServerStorage.Shuriken -- Change "Sword" to the name of your tool, make sure your tool is in ServerStorage

hitPart.Touched:Connect(function(hit)
	if debounce == true then
		if hit.Parent:FindFirstChild("Humanoid") then
			local plr = game.Players:FindFirstChild(hit.Parent.Name)
			if plr then
				debounce = false
				hitPart.BrickColor = BrickColor.new("Bright red")
				tool:Clone().Parent = plr.Backpack
				wait(3) -- Change "3" to however long you want the player to have to wait before they can get the tool again
				debounce = true
				hitPart.BrickColor = BrickColor.new("Bright green")
			end
		end
	end
end)
--[[
	
	Searches a dictionary for a value and returns the key for it
	
	Functions.SearchDictionary(
		table,					<-- |REQ| 	Dictionary to search through
		search,					<-- |REQ| 	Search value
	)
	
--]]



return function(dictionary, search)
	--- Scan dictionary
	for key, value in pairs(dictionary) do
		if value == search then
			--- Matching key!
			return key
		end
	end
	
	--- No matching value
	return
end
-- 100 == 1  0 == 0  1/0.5

function JamCalculation()
	local L_170_
	if (math.random(1, 100) <= L_24_.JamChance) then	
		L_170_ = true
		L_71_ = true
	else
		L_170_ = false
	end
	return L_170_
end

function TracerCalculation()
	local L_171_
	if (math.random(1, 100) <= L_24_.TracerChance) then	
		L_171_ = true
	else
		L_171_ = false
	end
	return L_171_
end

function SearchResupply(L_172_arg1)
	local L_173_ = false
	local L_174_ = nil
	
	if L_172_arg1:FindFirstChild('ResupplyVal') or L_172_arg1.Parent:FindFirstChild('ResupplyVal') then
		L_173_ = true
		if L_172_arg1:FindFirstChild('ResupplyVal') then
			L_174_ = L_172_arg1.ResupplyVal
		elseif L_172_arg1.Parent:FindFirstChild('ResupplyVal') then
			L_174_ = L_172_arg1.Parent.ResupplyVal
		end
	end
	return L_173_, L_174_
end

function CheckReverb()
	local L_175_, L_176_ = workspace:FindPartOnRayWithIgnoreList(Ray.new(L_6_.CFrame.p, (L_6_.CFrame.upVector).unit * 30), IgnoreList);
		
	if L_175_ then
		local L_177_ = L_55_:WaitForChild('Fire'):FindFirstChild('ReverbSoundEffect') or Instance.new("ReverbSoundEffect", L_55_:WaitForChild('Fire'))
	elseif not L_175_ then
		if L_55_:WaitForChild('Fire'):FindFirstChild('ReverbSoundEffect') then
			L_55_.Fire.ReverbSoundEffect:Destroy()
		end
	end
end

function UpdateAmmo()
	L_29_.Text = L_95_
	L_30_.Text = L_29_.Text
	
	L_31_.Text = '| ' .. math.ceil(L_96_ / L_24_.StoredAmmo)
	L_32_.Text = L_31_.Text
	
	if L_87_ == 0 then
		L_40_.Image = 'rbxassetid://' .. 1868007495
	elseif L_87_ == 1 then
		L_40_.Image = 'rbxassetid://' .. 1868007947
	elseif L_87_ == 2 then
		L_40_.Image = 'rbxassetid://' .. 1868008584
	end
	
	if L_86_ == 1 then
		L_35_.BackgroundTransparency = 0
		L_36_.BackgroundTransparency = 0.7
		L_37_.BackgroundTransparency = 0.7
		L_38_.BackgroundTransparency = 0.7
		L_39_.BackgroundTransparency = 0.7
	elseif L_86_ == 2 then
		L_35_.BackgroundTransparency = 0
		L_36_.BackgroundTransparency = 0
		L_37_.BackgroundTransparency = 0
		L_38_.BackgroundTransparency = 0
		L_39_.BackgroundTransparency = 0
	elseif L_86_ == 3 then
		L_35_.BackgroundTransparency = 0
		L_36_.BackgroundTransparency = 0
		L_37_.BackgroundTransparency = 0
		L_38_.BackgroundTransparency = 0.7
		L_39_.BackgroundTransparency = 0.7
	elseif L_86_ == 4 then
		L_35_.BackgroundTransparency = 0
		L_36_.BackgroundTransparency = 0
		L_37_.BackgroundTransparency = 0
		L_38_.BackgroundTransparency = 0
		L_39_.BackgroundTransparency = 0.7
	elseif L_86_ == 5 then
		L_35_.BackgroundTransparency = 0
		L_36_.BackgroundTransparency = 0.7
		L_37_.BackgroundTransparency = 0
		L_38_.BackgroundTransparency = 0.7
		L_39_.BackgroundTransparency = 0.7
	elseif L_86_ == 6 then
		L_35_.BackgroundTransparency = 0
		L_36_.BackgroundTransparency = 0.7
		L_37_.BackgroundTransparency = 0
		L_38_.BackgroundTransparency = 0
		L_39_.BackgroundTransparency = 0.7
	end
	
end
-- We want to be able to override outputFunction in tests, so the shape of this
-- module is kind of unconventional.
--
-- We fix it this weird shape in init.lua.
local loggerMiddleware = {
	outputFunction = print,
}

function loggerMiddleware.middleware(nextDispatch, store)
	return function(action)
		local result = nextDispatch(action)

		loggerMiddleware.outputFunction(("Action dispatched: %s\nState changed to: %s"):format(
			prettyPrint(action),
			prettyPrint(store:getState())
		))

		return result
	end
end

return loggerMiddleware
--Put this script in game.StarterPlayer.StarterCharacterScripts
--Put the punch animation id on the animation inside this script

local humanoid = script.Parent.Humanoid

local mouse = game.Players.LocalPlayer:GetMouse()

mouse.Button1Down:Connect(function()
	if script.Parent:FindFirstChildOfClass("Tool") == nil and script.DamagePlayers.Debounce.Value == false then
		local punchTrack = humanoid:LoadAnimation(script.Animation)
		punchTrack:Play()
		script.RemoteEvent:FireServer()
		wait(script.Cooldown.Value)
		punchTrack:Stop()
	end
end)
------ VARIABLES ------

local tele = script.Parent
local padIsOneDirectional = tele:WaitForChild("OneWay")
local pad1 = tele:WaitForChild("Pad1")
local pad2 = tele:WaitForChild("Pad2")
local bounce = true
--------STAGE--------

game.Workspace.projection1.Decal.Texture = game.Workspace.Screens.ProjectionL.Value
game.Workspace.projection2.Decal.Texture = game.Workspace.Screens.ProjectionR.Value
--//Shifting//-
if key == "6" then
		 carSeat.Wheels.FR.Spring.Stiffness = 9000
 		 carSeat.Wheels.FL.Spring.Stiffness = 9000
elseif key == "5" then		 
	carSeat.Wheels.FR.Spring.Stiffness = 3500
	carSeat.Wheels.FL.Spring.Stiffness = 3500
	end
end)
-- Pause the shimmer
local function pauseShimmer()
	shim:Pause()
end
--[[
	Returns a new promise that:
		* is resolved when all input promises resolve
		* is rejected if ANY input promises reject
]]
function Promise._all(traceback, promises, amount)
	if type(promises) ~= "table" then
		error(string.format(ERROR_NON_LIST, "Promise.all"), 3)
	end

	-- We need to check that each value is a promise here so that we can produce
	-- a proper error rather than a rejected promise with our error.
	for i, promise in pairs(promises) do
		if not Promise.is(promise) then
			error(string.format(ERROR_NON_PROMISE_IN_LIST, "Promise.all", tostring(i)), 3)
		end
	end

	-- If there are no values then return an already resolved promise.
	if #promises == 0 or amount == 0 then
		return Promise.resolve({})
	end

	return Promise._new(traceback, function(resolve, reject, onCancel)
		-- An array to contain our resolved values from the given promises.
		local resolvedValues = {}
		local newPromises = {}

		-- Keep a count of resolved promises because just checking the resolved
		-- values length wouldn't account for promises that resolve with nil.
		local resolvedCount = 0
		local rejectedCount = 0
		local done = false

		local function cancel()
			for _, promise in ipairs(newPromises) do
				promise:cancel()
			end
		end

		-- Called when a single value is resolved and resolves if all are done.
		local function resolveOne(i, ...)
			if done then
				return
			end

			resolvedCount = resolvedCount + 1

			if amount == nil then
				resolvedValues[i] = ...
			else
				resolvedValues[resolvedCount] = ...
			end

			if resolvedCount >= (amount or #promises) then
				done = true
				resolve(resolvedValues)
				cancel()
			end
		end

		onCancel(cancel)

		-- We can assume the values inside `promises` are all promises since we
		-- checked above.
		for i, promise in ipairs(promises) do
			newPromises[i] = promise:andThen(
				function(...)
					resolveOne(i, ...)
				end,
				function(...)
					rejectedCount = rejectedCount + 1

					if amount == nil or #promises - rejectedCount < amount then
						cancel()
						done = true

						reject(...)
					end
				end
			)
		end

		if done then
			cancel()
		end
	end)
end
-------- OMG HAX

r = game:service("RunService")


local damage = 5


local slash_damage = 8
local lunge_damage = 12

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


local SlashSound = Instance.new("Sound")
SlashSound.SoundId = "rbxasset://sounds\\swordslash.wav"
SlashSound.Parent = sword
SlashSound.Volume = .7

local LungeSound = Instance.new("Sound")
LungeSound.SoundId = "rbxasset://sounds\\swordlunge.wav"
LungeSound.Parent = sword
LungeSound.Volume = .6

local UnsheathSound = Instance.new("Sound")
UnsheathSound.SoundId = "rbxasset://sounds\\unsheath.wav"
UnsheathSound.Parent = sword
UnsheathSound.Volume = 1


function blow(hit)
	local humanoid = hit.Parent:findFirstChild("Humanoid")
	local vCharacter = Tool.Parent
	local vPlayer = game.Players:playerFromCharacter(vCharacter)
	local hum = vCharacter:findFirstChild("Humanoid") -- non-nil if tool held by a character
	if humanoid~=nil and humanoid ~= hum and hum ~= nil then
		-- final check, make sure sword is in-hand

		local right_arm = vCharacter:FindFirstChild("Right Arm")
		if (right_arm ~= nil) then
			local joint = right_arm:FindFirstChild("RightGrip")
			if (joint ~= nil and (joint.Part0 == sword or joint.Part1 == sword)) then
				tagHumanoid(humanoid, vPlayer)
				humanoid:TakeDamage(damage)
				wait(1)
				untagHumanoid(humanoid)
			end
		end


	end
end


function tagHumanoid(humanoid, player)
	local creator_tag = Instance.new("ObjectValue")
	creator_tag.Value = player
	creator_tag.Name = "creator"
	creator_tag.Parent = humanoid
end

function untagHumanoid(humanoid)
	if humanoid ~= nil then
		local tag = humanoid:findFirstChild("creator")
		if tag ~= nil then
			tag.Parent = nil
		end
	end
end


function attack()
	damage = slash_damage
	SlashSound:play()
	local anim = Instance.new("StringValue")
	anim.Name = "toolanim"
	anim.Value = "Slash"
	anim.Parent = Tool
end

function lunge()
	damage = lunge_damage

	LungeSound:play()

	local anim = Instance.new("StringValue")
	anim.Name = "toolanim"
	anim.Value = "Lunge"
	anim.Parent = Tool
	
	
	force = Instance.new("BodyVelocity")
	force.velocity = Vector3.new(0,10,0) --Tool.Parent.Torso.CFrame.lookVector * 80
	force.Parent = Tool.Parent.Torso
	wait(.3)
	swordOut()
	wait(.3)
	force.Parent = nil
	wait(.5)
	swordUp()

	damage = slash_damage
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

function swordAcross()
	-- parry
end


Tool.Enabled = true
local last_attack = 0
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

	t = r.Stepped:wait()

	if (t - last_attack < .2) then
		lunge()
	else
		attack()
	end

	last_attack = t

	--wait(.5)

	Tool.Enabled = true
end


function onEquipped()
	UnsheathSound:play()
end


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


connection = sword.Touched:connect(blow)
--force.maxForce = Vector3.new(200,0,200)
gyro.maxTorque = Vector3.new(50000,500000,500000)
gyro.cframe = CFrame.fromEulerAnglesXYZ(math.pi/2,math.pi,-math.pi/2+ math.random(-2*math.pi,2*math.pi))

current_look = math.random(-2*math.pi,2*math.pi)

math.randomseed(tick())
math.random()
function idle()
	wait(math.random(3,10))
end
function lookaround()
	for i=1,math.random(2,3) do
		wait(math.random(.5,2))
		current_look = current_look + math.random(-math.pi/6,math.pi/6)
		gyro.cframe = CFrame.fromEulerAnglesXYZ(math.pi/2,math.pi,-math.pi/2+ current_look)
	end
end
function walk()
	for i=1,math.random(2,10) do
		
	current_look = current_look + math.random(-math.pi/4,math.pi/4)
	gyro.cframe = CFrame.fromEulerAnglesXYZ(math.pi/2,math.pi,-math.pi/2+ current_look)
	wait(math.random(.5,2))
	force.velocity = (script.Parent.CFrame * CFrame.fromEulerAnglesXYZ(0,math.pi/2,0)).lookVector * 100
	force.maxForce = Vector3.new(160,0,160)
	wait(math.random(.5,1))
	force.maxForce = Vector3.new(0,0,0)
	wait(math.random(1,1.5))
	end
end

while true do--math.random(0,2*math.pi)
	wait()
	local rand =  math.random(1,4)
	if rand == 1 then
		walk()
	elseif rand == 2 or rand == 4 then
		lookaround()
	else
		idle()
	end
end