local D=game:GetService("\068\101\098\114\105\115")local J=game:GetService("\084\119\101\101\110\083\101\114\118\105\099\101")local I=game.ReplicatedStorage.Skill:FindFirstChild(skillName)local f=true local z=false function tween(D,I,f,z)local T={Position=Vector3.new(D,I,f)}local g=TweenInfo.new(.2,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false)local y=J:Create(z,g,T)y:Play()end script.Parent.SkillEvent.OnServerEvent:Connect(function(J,T,g,y,Z)if f==true then if Ammo>0 then Ammo-=1 local J=I:Clone()J.Parent=game.Workspace.SkillPart J.Orientation=script.Parent.Handle.Orientation J.Position=script.Parent.Handle.Position J.Touched:Connect(function(I)local f=I.Parent:FindFirstChild("\072\117\109\097\110\111\105\100")local T=I.Parent.Parent:FindFirstChild("\072\117\109\097\110\111\105\100")if I~=script.Parent.Handle then local I=game.ReplicatedStorage.Skill.Explosion2:Clone()I.Parent=game.Workspace.SkillPart I.Position=Vector3.new(J.Position.X,J.Position.Y,J.Position.Z)D:AddItem(I,.2)D:AddItem(J,Delete)end if f~=nil and I.Parent then if I.Parent.Name==script.Parent.Parent.Name and z==false then return end if f and z==false then z=true f:TakeDamage(Damage)wait(DamageCoolTime)z=false elseif T and z==false then z=true T:TakeDamage(Damage)wait(DamageCoolTime)z=false end end end)tween(T,g,y,J);(script.Parent.Handle:FindFirstChild(Sound)):Play()elseif Ammo==0 then f=false Ammo=5 wait(CoolTime)f=true end end end)


local ser = game:GetService("Debris")
local tweenService = game:GetService("TweenService")
local skill = game.ReplicatedStorage.Skill:FindFirstChild(skillName) --스킬 찾기
local Cooldown = true
local DamageCool = false

function tween(X, Y, Z, clone)
	local Posi = {Position = Vector3.new(X, Y, Z)}

	local info = TweenInfo.new(
		0.2,
		Enum.EasingStyle.Linear,
		Enum.EasingDirection.Out,
		0,
		false
	)

	local tween = tweenService:Create(clone, info, Posi)
	tween:Play()
end

script.Parent.SkillEvent.OnServerEvent:Connect(function(plr, X, Y, Z, Target) --플레이어가 스킬을 클릭하면
	if Cooldown == true then
		if Ammo > 0 then
			Ammo -= 1
			local clone = skill:Clone() --스킬 복사
			clone.Parent = game.Workspace.SkillPart --스킬 적용
			clone.Orientation = script.Parent.Handle.Orientation
			clone.Position = script.Parent.Handle.Position
			
			clone.Touched:Connect(function(hit) --다른 플레이어가 스킬에 닿이면
				local human = hit.Parent:FindFirstChild("Humanoid") --휴머노이드 찾기
				local human2 = hit.Parent.Parent:FindFirstChild("Humanoid") --휴머노이드 찾기
				
				if hit ~= script.Parent.Handle then
					local bomb = game.ReplicatedStorage.Skill.Explosion2:Clone()
					bomb.Parent = game.Workspace.SkillPart
					bomb.Position = Vector3.new(clone.Position.X, clone.Position.Y, clone.Position.Z)
					
					ser:AddItem(bomb, 0.2)
					ser:AddItem(clone, Delete)
				end

				if human ~= nil and hit.Parent then
					if hit.Parent.Name == script.Parent.Parent.Name and DamageCool == false then return	end

					if human and DamageCool == false then --해당 조건이 맞으면

						DamageCool = true
						human:TakeDamage(Damage) --데미지 입히기
						wait(DamageCoolTime) --스킬 데미지 쿨타임 기다리기
						DamageCool = false

					elseif human2 and DamageCool == false then

						DamageCool = true
						human2:TakeDamage(Damage) --데미지 입히기
						wait(DamageCoolTime) --스킬 데미지 쿨타임 기다리기
						DamageCool = false
					end
				end 
			end) --끝

			tween(X, Y, Z, clone)

			script.Parent.Handle:FindFirstChild(Sound):Play() --오디오 틀기
			
		elseif Ammo == 0 then --탄환이 0이 되면
			Cooldown = false
			Ammo = 5 --다시 탄환 충전
			wait(CoolTime) --쿨타임
			Cooldown = true
		end
	end
end) --끝
