Quick actions

cmd+k|ctrl+k

Navigation

Languages

spells

Snippet info

Language

Lua

Visibility

public

Author

lazarovalkyrie

Created

2024-01-21T20:22:47.914786Z

Updated

2024-01-24T22:03:48.180285Z

-- animator

local function init()
	local JointData = {}
	JointData["Right Shoulder"] = CFrame.new(1, 0.5, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
	JointData["Left Shoulder"] = CFrame.new(-1, 0.5, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
	JointData["Right Hip"] = CFrame.new(1, -1, 0, 0, 0, 1, 0, 1, -0, -1, 0, 0)
	JointData["Left Hip"] = CFrame.new(-1, -1, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0)
	JointData["Neck"] = CFrame.new(0, 1, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)
	JointData["RootJoint"] = CFrame.new(0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 1, -0)

	local Animator = {}
	local Playing = {}
	local GlobalPlaying = {}
	local JointC0 = {}

	local TS = game:GetService("TweenService")

	local function Ver(Model)
		if Model and Model.Parent then
			if not Playing[Model] then
				Playing[Model] = {}
				return true
			end
		end
	end

	local function Play(self, FadeIn, Speed, Looped)
		self.TimePosition = 0
		self.StartInternal = os.clock()

		self.FadeIn = FadeIn or 0
		self.Speed = Speed or self.Speed
		self.Looped = Looped or self.Looped
		self.LastPlayed = os.clock()
		self.fired = {}
		self.RecoverFade = {}

		local StopEvent = Instance.new("BindableEvent")
		self.Stopped = StopEvent.Event
		self.StopEvent = StopEvent

		local LoopedEvent = Instance.new("BindableEvent")
		self.OnLooped = LoopedEvent.Event
		self.LoopedEvent = LoopedEvent

		local KeyframeReachedEvent = Instance.new("BindableEvent")
		self.KeyframeReached = KeyframeReachedEvent.Event
		self.KeyframeReachedEvent = KeyframeReachedEvent

		local MarkerReachedEvent = Instance.new("BindableEvent")
		self.MarkerReached = MarkerReachedEvent.Event
		self.MarkerReachedEvent = MarkerReachedEvent

		local I = Playing[self.Model]
		self.Playing = true
		I[self] = true
	end

	local function Stop(self,fire)
		local I = Playing[self.Model]
		if I then
			if fire then
				self.StopEvent:Fire()
			end
		end

		self.LastPlayed = 0
		self.Playing = false
		I[self] = nil

		self.Stopped = nil
		if self.StopEvent then
			self.StopEvent:Destroy()
		end
		self.StopEvent = nil

		self.OnLooped = nil
		if self.StopEvent then
			self.LoopedEvent:Destroy()
		end
		self.LoopedEvent = nil

		self.KeyframeReached = nil
		if self.StopEvent then
			self.KeyframeReachedEvent:Destroy()
		end
		self.KeyframeReachedEvent = nil

		self.MarkerReached = nil
		if self.StopEvent then
			self.MarkerReachedEvent:Destroy()
		end
		self.MarkerReachedEvent = nil

		self.FadeIn = nil
	end

	local function Resume(self)
		if self.PauseInternal then
			self.StartInternal = os.clock() - self.PauseInternal
		end
		local I = Playing[self.Model]
		self.Playing = true
		I[self] = true
	end

	local function Pause(self)
		local TimeSince = os.clock() - self.StartInternal
		self.PauseInternal = TimeSince
		local I = Playing[self.Model]
		self.Playing = false
		I[self] = nil
	end

	local function SetTime(self, Time)
		self.StartInternal = os.clock() - Time
	end

	local function AdjustSpeed(self, NewSpeed)
		self.Speed = NewSpeed
	end

	local function ft(t,c)
		for i,v in pairs(t) do
			if i == 'Parent' or i == 'Name' or i == 'Marker' or i == 'Time' or i == 'CF' then continue end
			if tonumber(i) and not v.CF then
				v.Time = tonumber(i)
			end
			if typeof(v) == 'table' then
				ft(v,true)
				local name = v.Name
				v.Name = nil
				v = setmetatable(v,{
					__index = {
						Parent = t,
						Name = name or i,
					}
				})
			end
		end
		return t
	end

	local function iter(t)
		local new_t,n = {},0
		for i,v in pairs(t) do
			if i == 'Parent' or i == 'CF' then continue end
			n = n + 1
			new_t[n] = v
			if typeof(v) == 'table' then
				for ii,vv in pairs(iter(v)) do
					n = n + 1
					new_t[n] = vv
				end
			end
		end
		return new_t,n
	end

	local Animations = {}

	function Animator.LoadAnimation(Track, Model)
		assert(Track,'No track.')
		assert(Model,'No model.')
		if Animations[Track] then
			return Animations[Track]
		end
		local Animation = {}
		Animations[Track] = Animation

		Track.Properties.Priority = Enum.AnimationPriority[Track.Properties.Priority]
		Track.Keyframes = ft(Track.Keyframes)

		local kf = Track.Keyframes
		table.sort(kf, function(a, b) return a.Time < b.Time end)
		local Keyframes = {}

		local set_model = Ver(Model)

		local largest_time = 0

		if true then
			local Joints = {}

			local function set_joint()
				for STime, SKeyframe in next, kf do
					STime = tonumber(STime)
					if STime > largest_time then
						largest_time = STime
					end

					local descendants,n = iter(SKeyframe)

					local function set_marker(name)
						if not Keyframes['_null'] then
							Keyframes['_null'] = {}
						end
						Keyframes['_null'][#Keyframes['_null'] + 1] = {Time = STime, Name = name, Marker = 1, ["Info"] = nil}
					end

					if 0 >= n then
						set_marker(SKeyframe.Name)
					end
					for _,Pose in next, descendants do
						if typeof(Pose) ~= 'table' then continue end
						if Pose.Name == 'HumanoidRootPart' then continue end

						if Pose.Marker then
							set_marker(Pose.Name)
						end

						local P0Name = Pose.Parent.Name
						local P1Name = Pose.Name
						local IP0 = Joints[Pose.Parent.Name]
						if not IP0 then continue end
						local Joint = IP0[Pose.Name]
						if not Joint then continue end

						local JT = Keyframes[Joint]
						if not JT then
							JT = {}
							Keyframes[Joint] = JT
							if not JointC0[Joint] then
								local jd = JointData[Joint.Name]
								if jd then
									Joint.C0 = jd
									JointC0[Joint] = jd
								else
									JointC0[Joint] = Joint.C0
								end
							end
						end

						local Style = Pose.ES or 'Linear'
						local Direction = Pose.ED or 'In'
						local Weight = Pose.Weight or 1
						local PCF = Pose.CF

						if not PCF then continue end

						local CF
						for i,v in pairs(PCF) do
							PCF[i] = tonumber(v)
						end

						if PCF[1] then
							CF = CFrame.new(PCF[1],PCF[2],PCF[3])
						else
							CF = CFrame.new()
						end
						if PCF[4] then
							CF = CF*CFrame.Angles(math.rad(PCF[4]),math.rad(PCF[5]),math.rad(PCF[6]))
						end

						local Info = {EasingStyle = Style, EasingDirection = Direction, Weight = Weight, CFrame = CF}

						if not GlobalPlaying[Animation] then
							GlobalPlaying[Animation] = {}
						end
						GlobalPlaying[Animation][Joint.Name] = 1

						JT[#JT+1] = {Time = STime, Name = SKeyframe.Name, ["Info"] = Info}
					end
				end
				Animation.Keyframes = Keyframes
				for Joint,Poses in pairs(Keyframes) do
					table.sort(Poses, function(a, b) return a.Time < b.Time end)
				end
				if not Animation.using then
					Animation.using = {}
				end
				for i,v in pairs(iter(Track.Keyframes)) do
					if typeof(v) == 'table' and v.CF then
						Animation.using[v.Name] = 1
					end
				end
			end

			local function new_joint(Obj,d)
				if Obj:IsA("Weld") then
					local P0 = Obj.Part0
					local P1 = Obj.Part1
					if not P0 or not P1 then return end

					local jd = JointData[Obj.Name]
					if jd then
						Obj.C0 = jd
						JointC0[Obj] = jd
					end

					local T = Joints[P0.Name]
					if not T then
						T = {}
						Joints[P0.Name] = T
					end
					T[P1.Name] = Obj
					--if not d then
					set_joint()
					--end
				end
			end

			for _,obj in next, Model:GetDescendants() do
				new_joint(obj)
			end

			Model.DescendantAdded:Connect(new_joint)

			set_joint()
		end
		Animation.TimePosition = 0
		Animation.TimeLength = largest_time
		Animation.kf = kf
		Animation.Track = Track
		Animation.Model = Model
		Animation.TimeScale = 1
		Animation.GeneralWeight = 1
		Animation.Play = Play
		Animation.Stop = Stop
		Animation.Resume = Resume
		Animation.Pause = Pause
		Animation.SetTime = SetTime
		Animation.AdjustSpeed = AdjustSpeed
		Animation.Looped = Track.Properties.Looping or false
		Animation.Speed = 1
		Animation.FadeIn = 0
		Animation.LastPlayed = 0
		Animation.i = 0
		Animation.Playing = false
		Animation.fired = {}
		Animation.RecoverFade = {}

		if Track.Properties.Priority == Enum.AnimationPriority.Core then
			Animation.Priority = 0
		elseif Track.Properties.Priority == Enum.AnimationPriority.Idle then
			Animation.Priority = 1
		elseif Track.Properties.Priority == Enum.AnimationPriority.Movement then
			Animation.Priority = 2
		elseif Track.Properties.Priority == Enum.AnimationPriority.Action then
			Animation.Priority = 3
		end

		Animation.StartInternal = 0
		Animation.PauseInternal = 0

		Animation.GetTimeOfKeyframe = function(name)
			for Time,v in ipairs(Keyframes) do
				if v.Name == name then
					return Time
				end
			end
		end

		return Animation
	end

	local CF = CFrame.new()
	local function GetPose(TimeSince, Poses, Joint)
		for i = 1,#Poses do
			local Keyframe = Poses[i]
			local NextKeyframe = Poses[i+1]
			local Time = Keyframe.Time

			--local JT = Joint.Transform
			if (TimeSince >= Time) or Poses[1].Time > TimeSince then
				if NextKeyframe then
					local NextTime = NextKeyframe.Time
					if TimeSince < NextTime then
						if Keyframe.Marker then
							return {nil, nil, Keyframe.Name, Time, Keyframe.Marker}
						end
						local Info1 = Keyframe.Info
						local Info2 = NextKeyframe.Info

						local Alpha = (TimeSince - Time) / (NextTime - Time)

						local CFA = CF:Lerp(Info1.CFrame, Info1.Weight)
						local CFB = CF:Lerp(Info2.CFrame, Info2.Weight)

						local Pose = CFA:Lerp(CFB, TS:GetValue(Alpha, Enum.EasingStyle[Info2.EasingStyle], Enum.EasingDirection[Info2.EasingDirection]))

						return {Joint, Pose, Keyframe.Name, Time}
					end
				else
					if Keyframe.Marker then
						return {nil, nil, Keyframe.Name, Time, Keyframe.Marker}
					end
					return {Joint, Keyframe.Info.CFrame, Keyframe.Name, Time}
				end
			end
		end
	end

	local total_playing = 0

	local function UpdatePlaying()
		local tp = 0
		for Model, Animations in next, Playing do
			for Animation,_ in next, Animations do
				if not Model or not Model.Parent then
					Playing[Model] = nil
					Animation.FadeIn = nil
					Animation.fired = {}
					Animation.Playing = false

					continue
				end

				local TimeSince = Animation.StartInternal
				TimeSince = os.clock() - ((os.clock() - TimeSince) * Animation.Speed)
				TimeSince = os.clock() - TimeSince
				--TimeSince = TimeSince * Animation.Speed

				if Animation.FadeIn then
					Animation.OFadeIn = Animation.FadeIn
				end

				local Length = Animation.TimeLength

				if TimeSince > Length then
					Animation.FadeIn = nil
					Animation.fired = {}
					if Animation.Looped then
						Animation.LoopedEvent:Fire()
						if 0 >= Length then
							TimeSince = 0
						else
							TimeSince = TimeSince%Length
						end
						--Animation.StartInternal += Length-TimeSince
					else
						Animation.TimePosition = 0
						Playing[Model][Animation] = nil
						Animation.Playing = false
						Animation.StopEvent:Fire()
						continue
					end
				end

				local Keyframes = Animation.Keyframes

				if Keyframes then else continue end
				tp += 1
				local ToAnimate = {}
				local StartFade = nil
				for Joint, Poses in pairs(Keyframes) do
					if not Poses[1] or not Poses[1].Marker then
						local f,fade
						for i,using in pairs(GlobalPlaying) do
							if i ~= Animation then else
								continue
							end
							if i.Playing then else
								continue
							end
							if using[Joint.Name] then else
								continue
							end
							if i.Priority > Animation.Priority or (i.Priority == Animation.Priority and i.LastPlayed > Animation.LastPlayed) then else
								continue
							end
							f = true
						end
						if f then
							Animation.RecoverFade[Joint.Name] = os.clock()
							continue
						end
					end
					if Poses[1] and Poses[1].Time > TimeSince then
						--StartFade = Poses[1].Time * Animation.Speed
					end
					ToAnimate[#ToAnimate+1] = GetPose(TimeSince, Poses, Joint)
				end
				for i = 1,#ToAnimate do
					local Pose = ToAnimate[i]
					if not Pose[5] then
						local TCF = Pose[2]
						local FadeIn = Animation.FadeIn
						local RF = Animation.RecoverFade[Pose[1].Name]
						local TimeSince = TimeSince
						if RF then
							TimeSince = os.clock()-RF
							if TimeSince >= Length then
								Animation.RecoverFade[Pose[1].Name] = nil
							else
								FadeIn = Animation.OFadeIn
							end
						end
						TCF = JointC0[Pose[1]] * TCF
						if StartFade then
							TCF = Pose[1].C0:Lerp(TCF, TimeSince / StartFade)
						elseif FadeIn and TimeSince < FadeIn then
							TCF = Pose[1].C0:Lerp(TCF, TimeSince / FadeIn)
						end
						Pose[1].C0 = TCF
					end
					if not Animation.fired[Pose[3] .. Pose[4]] and Pose[3] ~= 'Keyframe' then
						Animation.fired[Pose[3] .. Pose[4]] = 1
						if not Pose[4] then -- keyframe
							Animation.KeyframeReachedEvent:Fire(Pose[3])
						elseif Pose[5] then -- keymarker
							Animation.MarkerReachedEvent:Fire(Pose[3])
						end
					end
				end

				Animation.TimePosition = TimeSince
			end
		end
		total_playing = tp
	end

	function Animator.GetPlaying()
		return total_playing
	end

	local con
	if game:GetService("RunService"):IsClient() then
		con = game:GetService("RunService").RenderStepped:Connect(UpdatePlaying)
	else
		con = game:GetService("RunService").Stepped:Connect(UpdatePlaying)
	end

	return Animator,con
end

-- anims

local default_anims = game:GetService("HttpService"):GetAsync('https://glot.io/snippets/gsoh9bt5uw/raw')
default_anims = game:GetService("HttpService"):JSONDecode(default_anims)

-- anims

local anims = game:GetService("HttpService"):GetAsync('https://glot.io/snippets/gsoh9ttxxj/raw')
anims = game:GetService("HttpService"):JSONDecode(anims)

-- starter

local plr = owner
local char = plr.Character
local hum = char:FindFirstChildOfClass("Humanoid")
local root = char:FindFirstChild("HumanoidRootPart")

if hum.RigType == Enum.HumanoidRigType.R6 then else
	warn('Humanoid is not R6')
	return
end

--

local animate = char.Animate
local animator = hum.Animator

local anim_welds = {}
local char_welds = {}

for i,v in pairs(char:GetDescendants()) do
	if v:IsA("Motor6D") then
		local m = Instance.new("Weld")
		m.Name = v.Name
		m.Part0 = v.Part0
		m.Part1 = v.Part1
		m.C0 = v.C0
		m.C1 = v.C1
		m.Parent = v.Parent

		anim_welds[m] = m.Part0
		char_welds[v] = v.Part0
	end
end

local idle_anim = Instance.new("Animation")
idle_anim.AnimationId = 'rbxassetid://125750544'
idle_anim.Parent = hum

local taid = 0

function toggle_anim(mode)
	taid += 1
	local cid = taid

	local function run()
		if cid == taid then else return end
		if mode then
			for i,v in pairs(anim_welds) do
				i.Part0 = v
			end
		else
			for i,v in pairs(anim_welds) do
				i.Part0 = nil
			end
		end
	end

	if not mode then
		task.delay(0.2,run)
	else
		run()
	end

	return cid
end

function get_aid()
	return taid
end

--

local animator,con = init()

function load(anim)
	return animator.LoadAnimation(anim,char)
end

local move_anims = {
	fall = {
		anim = load(default_anims.fall),
		fade = 0.3,
	},
	climb = {
		anim = load(default_anims.climb),
		fade = 0.2,
	},
	jump = {
		anim = load(default_anims.jump),
		fade = 0.2,
	},
	walk = {
		anim = load(default_anims.walk),
		fade = 0.2,
	},
	idle = {
		anim = load(default_anims.idle),
		fade = 0.3,
	},
	sit = {
		anim = load(default_anims.sit),
		fade = 0.5,
	},
}

local jumped = false
local current_move = nil

function play_move_anim(cid)
	if not cid then
		for id,data in pairs(move_anims) do
			if data.anim.Playing then
				data.anim:Stop()
			end
		end
		return
	end
	local data = move_anims[cid]
	if cid == 'walk' then
		data.anim:AdjustSpeed(hum.WalkSpeed/16)
	end
	if not data.anim.Playing then
		local old_data = move_anims[current_move]
		if old_data then
			old_data.anim:Stop()
		end
		current_move = cid
		data.anim:Play(data.fade, nil, true)
	end
end

--

function sleep(n)
	return task.wait(n or 0)
end

local function wrap(func)
	coroutine.resume(coroutine.create(func))
end

function play_sound(par,id,vol,speed,loop,perm)
	local s = Instance.new("Sound")
	s.SoundId = 'rbxassetid://' .. id
	s.Volume = vol or 0.5
	s.PlaybackSpeed = speed or 1
	s.Looped = loop or false
	s.Parent = par or root
	if not perm then
		s:Play()
	end
	if not loop and not perm then
		s.Ended:Connect(function()
			sleep()
			s:Destroy()
		end)
	end
	return s
end

--

local cs = game:GetService("CollectionService")

do
	local tool = Instance.new("Tool")
	tool.Name = 'Ignis'
	tool.RequiresHandle = false
	tool.CanBeDropped = false
	tool.Parent = plr:FindFirstChildOfClass("Backpack")

	cs:AddTag(tool,'spell')

	local debounce = false
	local cid

	local function stop()
		cs:RemoveTag(tool,'using')
		debounce = true
		if cid == get_aid() then
			toggle_anim(false)
		end
		task.delay(2,function()
			debounce = false
		end)
	end

	local function check()
		if not cs:HasTag(tool,'using') or hum.PlatformStand then
			stop()
			return true
		end
	end

	local function use()
		cs:AddTag(tool,'using')

		local last
		for i = 1,6 do
			if check() then
				return
			end

			local anim = load(anims['wand' .. i])
			anim:Play(0.15)
			if last then
				last:Stop()
			end
			last = anim
			play_sound(root,1026964101,0.5,2)
			sleep(0.2)

		end

		if check() then
			return
		end

		local anim = load(anims.point)
		anim.Looped = true
		anim:Play(0.2)
		last:Stop()

		--local s = play_sound(root,9117988356,0.4,1)

		local s = play_sound(root,303632290,0.5,1,true)

		local params = OverlapParams.new()
		params.FilterDescendantsInstances = {char}
		params.FilterType = Enum.RaycastFilterType.Blacklist
		params.MaxParts = 100

		local ParticleEmitter0 = Instance.new("ParticleEmitter")
		ParticleEmitter0.Parent = char['Right Arm'].RightGripAttachment
		ParticleEmitter0.Speed = NumberRange.new(15, 15)
		ParticleEmitter0.Color = ColorSequence.new(Color3.new(1, 0.666667, 0),Color3.new(1, 0, 0))
		ParticleEmitter0.LightEmission = 0.5
		ParticleEmitter0.Texture = "rbxassetid://5234388158"
		ParticleEmitter0.Transparency = NumberSequence.new({
			NumberSequenceKeypoint.new(0,0),
			NumberSequenceKeypoint.new(0.7,0),
			NumberSequenceKeypoint.new(1,1),
		})
		ParticleEmitter0.Acceleration = Vector3.new(0,0,0)
		ParticleEmitter0.ZOffset = 0.5
		ParticleEmitter0.Size = NumberSequence.new({
			NumberSequenceKeypoint.new(0,0),
			NumberSequenceKeypoint.new(0.146,0.438),
			NumberSequenceKeypoint.new(0.875,0.875),
			NumberSequenceKeypoint.new(1,1.56),
		})
		ParticleEmitter0.EmissionDirection = Enum.NormalId.Bottom
		ParticleEmitter0.Lifetime = NumberRange.new(0.7, 0.7)
		ParticleEmitter0.LockedToPart = false
		ParticleEmitter0.Rate = 150
		ParticleEmitter0.RotSpeed = NumberRange.new(200, 200)
		ParticleEmitter0.SpreadAngle = Vector2.new(25, 25)
		ParticleEmitter0.VelocitySpread = 25
		ParticleEmitter0.Enabled = true

		local lbox

		local function fire()
			local hit = {}
			local box = Instance.new("Part")
			box.Transparency = 1
			box.Size = Vector3.new(5,5,8)
			box.CFrame = char['Right Arm'].CFrame * CFrame.new(0,-1-4.5-1,0)*CFrame.Angles(math.rad(90),0,0)
			box.Anchored = false
			box.CanCollide = false
			box.Massless = true
			box.Locked = true
			box.Parent = workspace

			if lbox then
				lbox:Destroy()
			end
			lbox = box

			for i,obj in ipairs(workspace:GetPartsInPart(box,params)) do
				local targchar = obj.Parent
				local targhum
				pcall(function()
					targhum = targchar:FindFirstChildOfClass("Humanoid")
				end)
				local targroot
				pcall(function()
					targroot = targchar:FindFirstChild("HumanoidRootPart") or targchar:FindFirstChild("Torso")
				end)
				if targchar and not hit[targchar] and targhum and targroot then
					hit[targchar] = {targchar,targroot,obj}
					local ms = targhum:GetAttribute('mana_shield')
					if ms and ms == 2 then
						return
					end
					local burning = targhum:GetAttribute('burning')
					targhum:SetAttribute('burning',os.clock())
					targhum:SetAttribute('freeze',nil)
					if not burning then
						local p = ParticleEmitter0:Clone()
						p.EmissionDirection = Enum.NormalId.Top
						p.LockedToPart = true
						p.Speed = NumberRange.new(1)
						p.SpreadAngle = Vector2.new(0, 0)
						p.Acceleration = Vector3.new(0,0,0)
						p.Color = ColorSequence.new(Color3.new(1, 0, 0),Color3.new(1, 0, 0))
						p.Texture = "rbxassetid://288279969"
						p.Rate = 100
						p.Parent = targroot

						local dir = (targroot.Position-root.Position).Unit

						local bvel = Instance.new("BodyVelocity")
						bvel.MaxForce = Vector3.new(1/0,1/0,1/0)
						bvel.Velocity = dir*40+Vector3.new(0,5,0)
						bvel.Parent = targroot
						game:GetService("Debris"):AddItem(bvel,0.1)

						local s = play_sound(targroot,303632290,0.5,1,true)

						coroutine.wrap(function()
							while true do
								burning = targhum:GetAttribute('burning') or 0
								if 13.75 >= os.clock()-burning and targchar and targchar.Parent then else
									if targhum then
										targhum:SetAttribute('burning',nil)
										targhum.PlatformStand = false
									end
									if p then
										p.Enabled = false
										task.delay(1.1,function()
											p:Destroy()
										end)
									end
									if s then
										s:Destroy()
									end
									break
								end
								if 2 >= os.clock()-burning then
									targhum.PlatformStand = true
								else
									targhum.PlatformStand = false
								end
								targhum:TakeDamage(3.5)
								sleep(0.5)
							end
						end)()
					end
				end
			end
		end

		local st = os.clock()

		repeat
			fire()
			sleep(0.1)
		until os.clock()-st >= 5 or check()

		anim:Stop()
		if s then
			s:Destroy()
		end
		if ParticleEmitter0 then
			ParticleEmitter0:Destroy()
		end

		stop()
	end

	tool.Activated:Connect(function()
		if debounce then
			return
		end
		if hum:GetAttribute('mana_shield') then
			return
		end
		if cs:HasTag(tool,'using') then
			return
		end
		cid = toggle_anim(true)
		use()
	end)
	tool.Unequipped:Connect(function()
		cs:RemoveTag(tool,'using')
	end)
end

do
	local tool = Instance.new("Tool")
	tool.Name = 'Gelidus'
	tool.RequiresHandle = false
	tool.CanBeDropped = false
	tool.Parent = plr:FindFirstChildOfClass("Backpack")

	cs:AddTag(tool,'spell')

	local debounce = false
	local cid

	local function stop()
		cs:RemoveTag(tool,'using')
		debounce = true
		if cid == get_aid() then
			toggle_anim(false)
		end
		task.delay(2,function()
			debounce = false
		end)
	end

	local function check()
		if not cs:HasTag(tool,'using') or hum.PlatformStand then
			stop()
			return true
		end
	end

	local function use()
		cs:AddTag(tool,'using')

		local last
		for i = 1,6 do
			if check() then
				return
			end

			local anim = load(anims['wand' .. i])
			anim:Play(0.15)
			if last then
				last:Stop()
			end
			last = anim
			play_sound(root,1026964101,0.5,2)
			sleep(0.2)

		end

		if check() then
			return
		end

		local anim = load(anims.point)
		anim.Looped = true
		anim:Play(0.2)
		last:Stop()

		--local s = play_sound(root,9117988356,0.4,1)

		local s = play_sound(root,362395087,0.5,1,true)

		local params = OverlapParams.new()
		params.FilterDescendantsInstances = {char}
		params.FilterType = Enum.RaycastFilterType.Blacklist
		params.MaxParts = 100

		local ParticleEmitter0 = Instance.new("ParticleEmitter")
		ParticleEmitter0.Parent = char['Right Arm'].RightGripAttachment
		ParticleEmitter0.Speed = NumberRange.new(15, 15)
		ParticleEmitter0.Color = ColorSequence.new(Color3.new(1, 1, 1),Color3.new(0.333333, 1, 1))
		ParticleEmitter0.LightEmission = 0.5
		ParticleEmitter0.Texture = "rbxassetid://5234388158"
		ParticleEmitter0.Transparency = NumberSequence.new({
			NumberSequenceKeypoint.new(0,0),
			NumberSequenceKeypoint.new(0.7,0),
			NumberSequenceKeypoint.new(1,1),
		})
		ParticleEmitter0.Acceleration = Vector3.new(0,0,0)
		ParticleEmitter0.ZOffset = 0.5
		ParticleEmitter0.Size = NumberSequence.new({
			NumberSequenceKeypoint.new(0,0),
			NumberSequenceKeypoint.new(0.146,0.438),
			NumberSequenceKeypoint.new(0.875,0.875),
			NumberSequenceKeypoint.new(1,1.56),
		})
		ParticleEmitter0.EmissionDirection = Enum.NormalId.Bottom
		ParticleEmitter0.Lifetime = NumberRange.new(0.7, 0.7)
		ParticleEmitter0.LockedToPart = false
		ParticleEmitter0.Rate = 150
		ParticleEmitter0.RotSpeed = NumberRange.new(200, 200)
		ParticleEmitter0.SpreadAngle = Vector2.new(25, 25)
		ParticleEmitter0.VelocitySpread = 25
		ParticleEmitter0.Enabled = true

		local lbox

		local function fire()
			local hit = {}
			local box = Instance.new("Part")
			box.Transparency = 1
			box.Size = Vector3.new(5,5,8)
			box.CFrame = char['Right Arm'].CFrame * CFrame.new(0,-1-4.5-1,0)*CFrame.Angles(math.rad(90),0,0)
			box.Anchored = false
			box.CanCollide = false
			box.Massless = true
			box.Locked = true
			box.Parent = workspace

			if lbox then
				lbox:Destroy()
			end
			lbox = box

			for i,obj in ipairs(workspace:GetPartsInPart(box,params)) do
				local targchar = obj.Parent
				local targhum
				pcall(function()
					targhum = targchar:FindFirstChildOfClass("Humanoid")
				end)
				local targroot
				pcall(function()
					targroot = targchar:FindFirstChild("HumanoidRootPart") or targchar:FindFirstChild("Torso")
				end)
				if targchar and not hit[targchar] and targhum and targroot then
					hit[targchar] = {targchar,targroot,obj}
					local ms = targhum:GetAttribute('mana_shield')
					if ms and ms == 2 then
						return
					end
					local freeze = targhum:GetAttribute('freeze')
					targhum:SetAttribute('freeze',os.clock())
					targhum:SetAttribute('burning',nil)
					if not freeze then
						targhum:TakeDamage(1)
						local Part0 = Instance.new("Part")
						Part0.CFrame = CFrame.new(-15.7232018, 3, 13.8946533, 1, 0, 0, 0, 1, 0, 0, 0, 1)
						Part0.Position = Vector3.new(-15.723201751708984, 3, 13.8946533203125)
						Part0.Color = Color3.new(0, 1, 1)
						Part0.Transparency = 0.5
						Part0.Size = Vector3.new(5, 6, 5)
						Part0.BottomSurface = Enum.SurfaceType.Smooth
						Part0.BrickColor = BrickColor.new("Toothpaste")
						Part0.Material = Enum.Material.Ice
						Part0.TopSurface = Enum.SurfaceType.Smooth
						Part0.brickColor = BrickColor.new("Toothpaste")
						Part0.Massless = true
						Part0.CanCollide = false
						Part0.Anchored = false

						local w = Instance.new("Motor6D")
						w.Part0 = targroot
						w.Part1 = Part0
						w.Parent = Part0

						Part0.Parent = targroot

						local dir = (targroot.Position-root.Position).Unit

						local bvel = Instance.new("BodyVelocity")
						bvel.MaxForce = Vector3.new(1/0,1/0,1/0)
						bvel.Velocity = dir*40+Vector3.new(0,5,0)
						bvel.Parent = targroot
						game:GetService("Debris"):AddItem(bvel,0.1)

						coroutine.wrap(function()
							while true do
								freeze = targhum:GetAttribute('freeze') or 0
								if 3 >= os.clock()-freeze and targchar and targchar.Parent then else
									if targhum then
										targhum:SetAttribute('freeze',nil)
										targhum.PlatformStand = false
									end
									if Part0 then
										Part0:Destroy()
									end
									break
								end
								targhum.PlatformStand = true
								sleep(0.1)
							end
						end)()
					end
				end
			end
		end

		local st = os.clock()

		repeat
			fire()
			sleep(0.1)
		until os.clock()-st >= 5 or check()

		anim:Stop()
		if s then
			s:Destroy()
		end
		if ParticleEmitter0 then
			ParticleEmitter0:Destroy()
		end

		stop()
	end

	tool.Activated:Connect(function()
		if debounce then
			return
		end
		if hum:GetAttribute('mana_shield') then
			return
		end
		if cs:HasTag(tool,'using') then
			return
		end
		cid = toggle_anim(true)
		use()
	end)
	tool.Unequipped:Connect(function()
		cs:RemoveTag(tool,'using')
	end)
end

do
	local holding = {}

	function block(input)
		if input.press then
			local hold = holding[input.key]
			local tool = char:FindFirstChildOfClass("Tool")
			local shield_type = 0
			if tool and cs:HasTag(tool,'spell') then
				shield_type = 2
				if not cs:HasTag(tool,'using') then else
					return
				end
			else
				shield_type = 1
			end
			
			if not hum.PlatformStand then else
				return
			end
			
			local Part0 = Instance.new("Part")
			Part0.CFrame = root.CFrame
			Part0.Color = Color3.fromRGB(111, 31, 217)
			Part0.Transparency = 0.7
			Part0.Size = Vector3.new(0,0,0)
			Part0.Shape = Enum.PartType.Ball
			Part0.Anchored = false
			Part0.CanCollide = false
			Part0.Massless = true
			Part0.Material = Enum.Material.Neon

			local w = Instance.new("Motor6D")
			w.Part0 = root
			w.Part1 = Part0
			w.Parent = Part0

			Part0.Parent = char

			hum:SetAttribute('mana_shield',shield_type)
			local exists = 1
			local hcc
			if shield_type == 2 then -- magic
				Part0.BrickColor = BrickColor.new("Royal purple")
				char.ChildRemoved:Connect(function(obj)
					if obj == tool then
						exists = nil
					end
				end)
			else -- physical
				Part0.BrickColor = BrickColor.new("Institutional white")
				local oldhp = hum.Health
				hcc = hum.HealthChanged:Connect(function(newhp)
					local change = oldhp-newhp
					if change > 0 then
						hum.Health = newhp + change
						local s = play_sound(root,8460106618,0.4)
					end
					oldhp = hum.Health
				end)
				exists = nil
				char.ChildAdded:Connect(function(obj)
					if obj:IsA("Tool") then
						exists = 1
					end
				end)
			end

			game:GetService("TweenService"):Create(Part0,TweenInfo.new(0.5),{
				Size = Vector3.new(7,7,7)
			}):Play()
			
			local function stop()
				if Part0 then
					game:GetService("TweenService"):Create(Part0,TweenInfo.new(0.5),{
						Size = Vector3.new(0,0,0)
					}):Play()
					game:GetService("Debris"):AddItem(Part0,0.5)
				end
				local s = play_sound(root,588735437,0.6)
				hum:SetAttribute('mana_shield',nil)
				if hcc then
					hcc:Disconnect()
				end
			end

			local s = play_sound(root,588734767,0.6)
			while true do
				if shield_type == 2 then
					if exists then else
						stop()
						break
					end
				else
					if not exists then else
						stop()
						break
					end
				end
				if hold == holding[input.key] and not hum.PlatformStand then else
					stop()
					break
				end
				sleep()
			end
		end
	end

	local keys = {
		[Enum.KeyCode.F] = block,
	}

	local remote = Instance.new("RemoteEvent")
	remote.Parent = char

	remote.OnServerEvent:Connect(function(lplr,mode,key)
		if plr == lplr and key then
			if not holding[key] then
				holding[key] = 0
			end
			holding[key] += 1
			local f = keys[key]
			if f then
				f({
					press = mode,
					key = key,
				})
			end
		end
	end)

	NLS([[
	local remote = script.Parent
	local uis = game:GetService("UserInputService")
	uis.InputBegan:Connect(function(input,press)
		if not press then else return end
		local key
		if input.UserInputType == Enum.UserInputType.Keyboard then
			key = input.KeyCode
		elseif input.UserInputType == Enum.UserInputType.MouseButton1 then
			key = Enum.UserInputType.MouseButton1
		elseif input.UserInputType == Enum.UserInputType.MouseButton2 then
			key = Enum.UserInputType.MouseButton2
		end
		if key then
			remote:FireServer(true,key)
		end
	end)
	uis.InputEnded:Connect(function(input,press)
		local key
		if input.UserInputType == Enum.UserInputType.Keyboard then
			key = input.KeyCode
		elseif input.UserInputType == Enum.UserInputType.MouseButton1 then
			key = Enum.UserInputType.MouseButton1
		elseif input.UserInputType == Enum.UserInputType.MouseButton2 then
			key = Enum.UserInputType.MouseButton2
		end
		if key then
			remote:FireServer(false,key)
		end
	end)
	]],remote)
end

--

toggle_anim(false)

print([[
Rogue Lineage
- Ignis and Gelidus
- F - Equipped - block magical
- F - Unequipped - block physical
]])

local c
c = game:GetService("RunService").Heartbeat:Connect(function()
	if not char or not char.Parent or 0 >= hum.Health then
		c:Disconnect()
		return
	end
	local dir = root.Velocity
	local params = RaycastParams.new()
	params.FilterType = Enum.RaycastFilterType.Blacklist
	params.FilterDescendantsInstances = {char}
	params.IgnoreWater = false
	local ground = workspace:Raycast(root.Position,root.CFrame.UpVector*-1*5,params)
	local jumpvel = dir.Y
	local walkvel = (dir*Vector3.new(1,0,1)).Magnitude
	local movevel = dir.Magnitude
	local faceDir = root.CFrame.lookVector.Unit
	local moveDir = dir.Unit
	local dot = faceDir:Dot(moveDir)

	local moving,air_state

	if walkvel > 0.01 then
		moving = true
	else
		moving = false
	end

	local state = hum:GetState()

	if state == Enum.HumanoidStateType.Freefall then
		air_state = 1
	elseif state == Enum.HumanoidStateType.Jumping then
		air_state = 2
	else
		air_state = 0
	end

	if state == Enum.HumanoidStateType.Jumping then
		jumped = true
	else
		jumped = false
	end

	if state == Enum.HumanoidStateType.Climbing then
		play_move_anim('climb')
	elseif hum.Sit then
		play_move_anim('sit')
	elseif air_state == 1 then
		play_move_anim('fall')
	elseif air_state == 2 then
		play_move_anim('jump')
	elseif moving then
		play_move_anim('walk')
	else
		play_move_anim('idle')
	end
end)
INFO