local h if debrisFolder:FindFirstChild("\077\111\099\104\105")then h=debrisFolder.Mochi else h=Instance.new("\070\111\108\100\101\114")h.Name="\077\111\099\104\105"h.Parent=debrisFolder end local L=partCacheMod.new(RS.FX.Mochi.MochiBall,300,h)local function x(h,x)local T=math.random(1,2)local m={RS.Sounds.Mochi.MochiFistHit1;RS.Sounds.Mochi.MochiFistHit2}for h,L in pairs(m)do local T=L:Clone()T.Parent=x T:Play()game.Debris:AddItem(T,2)end for x=1,T,1 do local T=(Random.new()):NextNumber(1,3)local m=L:GetPart()m.Size=Vector3.new(T,T,T)m.CFrame=CFrame.new(h)local B=CFrame.new(h)*CFrame.new((Random.new()):NextNumber(-30,30),15,(Random.new()):NextNumber(-30,30))local P=Ray.new(B.Position,Vector3.new(0,50,0))local D,M,X=workspace:FindPartOnRayWithIgnoreList(P,{m,debrisFolder})local e local C if D then C=h.Y-D.Position.Y e=Ray.new(Vector3.new(B.Position.X,C-1,B.Position.Z),Vector3.new(0,-1000,0))else C=50 e=Ray.new(B.Position,Vector3.new(0,-1000,0))end local J,f,Y=workspace:FindPartOnRayWithIgnoreList(e,{m;debrisFolder})if J then local h=CFrame.new(f,f+Y)*CFrame.Angles(-math.pi/2,0,0)local x=m.Position local T=h.Position local B=CFrame.new((x+T)/2)*(CFrame.new(0,(Random.new()):NextNumber(C*.25,C),0)).Position local P=(x-T).Magnitude local D=40 local M=(Random.new()):NextNumber(2,4)m.Parent=debrisFolder local X=bezierTween.Create(m,{Waypoints=Waypoints.new(x,B,T),EasingStyle=Enum.EasingStyle.Linear,EasingDirection=Enum.EasingDirection.In,Time=P/D})X:Play();(TS:Create(m,TweenInfo.new(P/D,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{Color=Color3.fromRGB(255,246,208)})):Play()X.Completed:Connect(function()m.CFrame=CFrame.new(f,f+Y)*CFrame.Angles(-math.pi/2,0,0);(TS:Create(m,TweenInfo.new(.18,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{Size=Vector3.new(M*2,.5,M*2)})):Play()task.delay(5,function()(TS:Create(m,TweenInfo.new(.6,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{Size=Vector3.new(0,0,0)})):Play()task.delay(.7,function()L:ReturnPart(m)end)end)end)else L:ReturnPart(m)end end end return function(h,T)local m=T.HumanoidRootPart local B=(Random.new()):NextNumber(1,2)local P=L:GetPart()P.Size=Vector3.new(B,B,B)local D=Ray.new(h+Vector3.new(0,1,0),Vector3.new(0,-50,0))local M,X,e=workspace:FindPartOnRayWithIgnoreList(D,{P,debrisFolder,T})local C=math.rad(math.random(360))if M then local h=(CFrame.new(X,X+e)*CFrame.Angles(-math.pi/2,0,0))*CFrame.Angles(0,C,0)local T=m.Position local B=h.Position local D=CFrame.new((T+B)/2)*(CFrame.new(0,(Random.new()):NextNumber(25,45),0)).Position local M=(T-B).Magnitude local J=100 local f=(Random.new()):NextNumber(8,14)P.Parent=debrisFolder local Y=bezierTween.Create(P,{Waypoints=Waypoints.new(T,D,B),EasingStyle=Enum.EasingStyle.Linear;EasingDirection=Enum.EasingDirection.In,Time=M/J})Y:Play();(TS:Create(P,TweenInfo.new(M/J,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{Color=Color3.fromRGB(255,246,208)})):Play()Y.Completed:Connect(function()P.CFrame=(CFrame.new(X,X+e)*CFrame.Angles(-math.pi/2,0,0))*CFrame.Angles(0,C,0)local h=RS.FX.Mochi.C.MochiCFloor:Clone()h.Size=Vector3.new(0,1,0)h.CFrame=P.CFrame L:ReturnPart(P)h.Parent=debrisFolder;(TS:Create(h,TweenInfo.new(.18,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{Size=Vector3.new(f*2,1.5,f*2)})):Play()local T={RS.FX.Mochi.C.Spike1,RS.FX.Mochi.C.Spike2,RS.FX.Mochi.C.Spike3}local m=T[math.random(1,#T)]:Clone()m.CFrame=h.CFrame task.delay(.7,function()m.Size=Vector3.new(h.Size.X*.45,.01,h.Size.Z*.5)m.Parent=debrisFolder local L=(Random.new()):NextNumber(20,35);(TS:Create(m,TweenInfo.new(.17,Enum.EasingStyle.Back,Enum.EasingDirection.Out),{Size=Vector3.new(m.Size.X,L,m.Size.Z);CFrame=((CFrame.new(X,X+e)*CFrame.Angles(-math.pi/2,0,0))*CFrame.new(0,L/2-2,0))*CFrame.Angles(0,C,0)})):Play()x(m.Position,m)for h,L in pairs(h.ExpFX:GetChildren())do L:Emit(L:GetAttribute("\069\109\105\116\067\111\117\110\116"))end task.delay(1,function()(TS:Create(m,TweenInfo.new(5,Enum.EasingStyle.Back,Enum.EasingDirection.Out),{Size=m.Size*.98,CFrame=(CFrame.new(X,X+e)*CFrame.Angles(-math.pi/2,0,0))*CFrame.new(0,(m.Size.Y*.98)/2-3,0)})):Play()task.delay(3,function()(TS:Create(m,TweenInfo.new(.45,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{Size=Vector3.new(f*2,.3,f*2),CFrame=CFrame.new(X,X+e)*CFrame.Angles(-math.pi/2,0,0)})):Play()task.delay(.45,function()(TS:Create(m,TweenInfo.new(.5,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{Size=Vector3.new()})):Play()game.Debris:AddItem(m,.6)end)end)end)end)task.delay(6,function()(TS:Create(h,TweenInfo.new(.6,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut),{Size=Vector3.new(0,0,0)})):Play()game.Debris:AddItem(h,.7)end)end)end end
-- CACHE --
local cacheFolder
if debrisFolder:FindFirstChild("Mochi") then
	cacheFolder = debrisFolder.Mochi
else
	cacheFolder = Instance.new("Folder")
	cacheFolder.Name = "Mochi"
	cacheFolder.Parent = debrisFolder
end

local partCache = partCacheMod.new(RS.FX.Mochi.MochiBall, 300, cacheFolder)

local function mochiExplosion(OriginPosition, OriginInstance)
	local amount = math.random(1, 2)

	local hitSFX = {
		RS.Sounds.Mochi.MochiFistHit1,
		RS.Sounds.Mochi.MochiFistHit2,
	}

	for sounds, sfx in pairs(hitSFX) do
		local clonedSFX = sfx:Clone()
		clonedSFX.Parent = OriginInstance
		clonedSFX:Play()
		game.Debris:AddItem(clonedSFX, 2)
	end

	for i = 1, amount do
		local mochiSize = Random.new():NextNumber(1, 3)
		local mochiPart = partCache:GetPart() --RS.FX.MochiDrip:Clone()
		mochiPart.Size = Vector3.new(mochiSize, mochiSize, mochiSize)
		mochiPart.CFrame = CFrame.new(OriginPosition)

		local rayCheck = CFrame.new(OriginPosition)
			* CFrame.new(Random.new():NextNumber(-30, 30), 15, Random.new():NextNumber(-30, 30))

		local roofCheckRay = Ray.new(rayCheck.Position, Vector3.new(0, 50, 0))
		local Rhit, Rvec2Pos, RsurfaceNormal =
			workspace:FindPartOnRayWithIgnoreList(roofCheckRay, { mochiPart, debrisFolder })

		local ray
		local maxHeight

		if Rhit then
			maxHeight = (OriginPosition.Y - Rhit.Position.Y)
			ray =
				Ray.new(Vector3.new(rayCheck.Position.X, maxHeight - 1, rayCheck.Position.Z), Vector3.new(0, -1000, 0))
		else
			maxHeight = 50
			ray = Ray.new(rayCheck.Position, Vector3.new(0, -1000, 0))
		end

		local hit, vec2Pos, surfaceNormal = workspace:FindPartOnRayWithIgnoreList(ray, { mochiPart, debrisFolder })

		if hit then
			local endCF = CFrame.new(vec2Pos, vec2Pos + surfaceNormal) * CFrame.Angles(-math.pi / 2, 0, 0)
			local p0 = mochiPart.Position
			local p2 = endCF.Position
			local p1 = CFrame.new((p0 + p2) / 2)
				* CFrame.new(0, Random.new():NextNumber(maxHeight * 0.25, maxHeight), 0).Position

			local distance = (p0 - p2).Magnitude
			local speed = 40

			local poolSize = Random.new():NextNumber(2, 4)

			mochiPart.Parent = debrisFolder

			local Tween = bezierTween.Create(mochiPart, {
				Waypoints = Waypoints.new(p0, p1, p2),
				EasingStyle = Enum.EasingStyle.Linear,
				EasingDirection = Enum.EasingDirection.In,
				Time = distance / speed,
			})

			Tween:Play()
			TS:Create(
				mochiPart,
				TweenInfo.new(distance / speed, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut),
				{ Color = Color3.fromRGB(255, 246, 208) }
			):Play()

			Tween.Completed:Connect(function()
				mochiPart.CFrame = CFrame.new(vec2Pos, vec2Pos + surfaceNormal) * CFrame.Angles(-math.pi / 2, 0, 0)
				TS:Create(
					mochiPart,
					TweenInfo.new(0.18, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut),
					{ Size = Vector3.new(poolSize * 2, 0.5, poolSize * 2) }
				):Play()
				task.delay(5, function()
					TS:Create(
						mochiPart,
						TweenInfo.new(0.6, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut),
						{ Size = Vector3.new(0, 0, 0) }
					):Play()
					--game.Debris:AddItem(mochiPart, .7)
					task.delay(0.7, function()
						partCache:ReturnPart(mochiPart)
					end)
				end)
			end)
		else
			partCache:ReturnPart(mochiPart)
		end
	end
end

return function(HitboxPos, Character)
	local HRP = Character.HumanoidRootPart
	local mochiSize = Random.new():NextNumber(1, 2)
	local mochiPart = partCache:GetPart()
	mochiPart.Size = Vector3.new(mochiSize, mochiSize, mochiSize)

	local ray = Ray.new(HitboxPos + Vector3.new(0, 1, 0), Vector3.new(0, -50, 0))
	local hit, vec2Pos, surfaceNormal =
		workspace:FindPartOnRayWithIgnoreList(ray, { mochiPart, debrisFolder, Character })
	local angle = math.rad(math.random(360))

	if hit then
		local endCF = CFrame.new(vec2Pos, vec2Pos + surfaceNormal)
			* CFrame.Angles(-math.pi / 2, 0, 0)
			* CFrame.Angles(0, angle, 0)
		local p0 = HRP.Position
		local p2 = endCF.Position
		local p1 = CFrame.new((p0 + p2) / 2) * CFrame.new(0, Random.new():NextNumber(25, 45), 0).Position

		local distance = (p0 - p2).Magnitude
		local speed = 100

		local poolSize = Random.new():NextNumber(8, 14)

		mochiPart.Parent = debrisFolder

		local Tween = bezierTween.Create(mochiPart, {
			Waypoints = Waypoints.new(p0, p1, p2),
			EasingStyle = Enum.EasingStyle.Linear,
			EasingDirection = Enum.EasingDirection.In,
			Time = distance / speed,
		})

		Tween:Play()
		TS:Create(
			mochiPart,
			TweenInfo.new(distance / speed, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut),
			{ Color = Color3.fromRGB(255, 246, 208) }
		):Play()

		Tween.Completed:Connect(function()
			mochiPart.CFrame = CFrame.new(vec2Pos, vec2Pos + surfaceNormal)
				* CFrame.Angles(-math.pi / 2, 0, 0)
				* CFrame.Angles(0, angle, 0)
			--mochiPart.Transparency = 1

			local mochiFloor = RS.FX.Mochi.C.MochiCFloor:Clone()
			mochiFloor.Size = Vector3.new(0, 1, 0)
			mochiFloor.CFrame = mochiPart.CFrame

			partCache:ReturnPart(mochiPart)

			mochiFloor.Parent = debrisFolder

			TS:Create(
				mochiFloor,
				TweenInfo.new(0.18, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut),
				{ Size = Vector3.new(poolSize * 2, 1.5, poolSize * 2) }
			):Play()

			local spikes = {
				RS.FX.Mochi.C.Spike1,
				RS.FX.Mochi.C.Spike2,
				RS.FX.Mochi.C.Spike3,
			}

			local mochiSpike = spikes[math.random(1, #spikes)]:Clone()
			mochiSpike.CFrame = mochiFloor.CFrame

			task.delay(0.7, function()
				mochiSpike.Size = Vector3.new(mochiFloor.Size.X * 0.45, 0.01, mochiFloor.Size.Z * 0.5)
				mochiSpike.Parent = debrisFolder
				local spikeHeight = Random.new():NextNumber(20, 35)
				--print(spikeHeight)
				TS:Create(
					mochiSpike,
					TweenInfo.new(0.17, Enum.EasingStyle.Back, Enum.EasingDirection.Out),
					{
						Size = Vector3.new(mochiSpike.Size.X, spikeHeight, mochiSpike.Size.Z),
						CFrame = CFrame.new(vec2Pos, vec2Pos + surfaceNormal)
							* CFrame.Angles(-math.pi / 2, 0, 0)
							* CFrame.new(0, spikeHeight / 2 - 2, 0)
							* CFrame.Angles(0, angle, 0),
					}
				):Play()

				mochiExplosion(mochiSpike.Position, mochiSpike)
				for i, v in pairs(mochiFloor.ExpFX:GetChildren()) do
					v:Emit(v:GetAttribute("EmitCount"))
				end

				task.delay(1, function()
					--warn(mochiSpike.Size)
					TS:Create(
						mochiSpike,
						TweenInfo.new(5, Enum.EasingStyle.Back, Enum.EasingDirection.Out),
						{
							Size = mochiSpike.Size * 0.98,
							CFrame = CFrame.new(vec2Pos, vec2Pos + surfaceNormal)
								* CFrame.Angles(-math.pi / 2, 0, 0)
								* CFrame.new(0, (mochiSpike.Size.Y * 0.98) / 2 - 3, 0),
						}
					):Play()
					task.delay(3, function()
						TS:Create(
							mochiSpike,
							TweenInfo.new(0.45, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut),
							{
								Size = Vector3.new(poolSize * 2, 0.3, poolSize * 2),
								CFrame = CFrame.new(vec2Pos, vec2Pos + surfaceNormal)
									* CFrame.Angles(-math.pi / 2, 0, 0),
							}
						):Play()
						task.delay(0.45, function()
							TS:Create(
								mochiSpike,
								TweenInfo.new(0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut),
								{ Size = Vector3.new() }
							):Play()
							game.Debris:AddItem(mochiSpike, 0.6)
						end)
					end)
				end)
			end)

			task.delay(6, function()
				TS:Create(
					mochiFloor,
					TweenInfo.new(0.6, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut),
					{ Size = Vector3.new(0, 0, 0) }
				):Play()
				game.Debris:AddItem(mochiFloor, 0.7)
			end)
		end)
	end
end
