Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- 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.StartInternal = os.clock() - ((os.clock() - self.StartInternal) * self.Speed)
- 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
- end
- local function new_joint(Obj,d)
- if Obj:IsA("Motor6D") 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,true)
- 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.using = {}
- Animation.fired = {}
- Animation.RecoverFade = {}
- for i,v in pairs(iter(Track.Keyframes)) do
- if typeof(v) == 'table' and v.CF then
- Animation.using[v.Name] = 1
- end
- end
- 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) 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 = os.clock() - Animation.StartInternal
- 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 = Length
- 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 = {}
- 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
- 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 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://hastebin.com/raw/qayoburehu')
- default_anims = game:GetService("HttpService"):JSONDecode(default_anims)
- -- anims
- local anims = game:GetService("HttpService"):GetAsync('https://hastebin.com/raw/ruzikagesi')
- 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
- --
- char.Archivable = true
- char.Animate.Disabled = true
- hum.Animator:Destroy()
- function weld(p1,p2,is,n)
- local m
- if is then
- m = Instance.new("Weld")
- else
- m = Instance.new("Motor6D")
- end
- m.Part0 = p1
- m.Part1 = p2
- m.Name = n or m.Part1.Name
- m.Parent = m.Part1.Parent
- return m
- end
- for i,v in pairs(char:GetDescendants()) do
- if v:IsA("Motor6D") then
- local m = Instance.new("Motor6D")
- m.Name = v.Name
- m.Part0 = v.Part0
- m.Part1 = v.Part1
- m.C0 = v.C0
- m.C1 = v.C1
- m.Parent = v.Parent
- v:Destroy()
- end
- end
- local blade = Instance.new("Part")
- blade.Name = 'blade'
- blade.Parent = char
- blade.Size = Vector3.new(0.5,5,0.5)
- blade.CanCollide = false
- blade.Anchored = false
- blade.Transparency = 1
- local w = weld(char['Right Arm'],blade,true)
- w.C1 = CFrame.new(0,-1.6,1.1)*CFrame.Angles(math.rad(90),0,0)
- local ParticleEmitter0 = Instance.new("ParticleEmitter")
- local ParticleEmitter1 = Instance.new("ParticleEmitter")
- ParticleEmitter0.Name = "Sparks"
- ParticleEmitter0.Parent = blade
- ParticleEmitter0.Speed = NumberRange.new(10, 17)
- ParticleEmitter0.Color = ColorSequence.new(Color3.new(1, 0.784314, 0),Color3.new(1, 1, 0.203922))
- ParticleEmitter0.Enabled = false
- ParticleEmitter0.LightEmission = 3
- ParticleEmitter0.Texture = "http://www.roblox.com/asset/?id=134531274"
- ParticleEmitter0.ZOffset = 2
- ParticleEmitter0.Size = NumberSequence.new(0.10000000149011612,0.10000000149011612)
- ParticleEmitter0.Acceleration = Vector3.new(0, -22, 0)
- ParticleEmitter0.EmissionDirection = Enum.NormalId.Front
- ParticleEmitter0.Lifetime = NumberRange.new(1, 1)
- ParticleEmitter0.Rate = 40
- ParticleEmitter0.SpreadAngle = Vector2.new(30, 30)
- ParticleEmitter0.VelocitySpread = 30
- ParticleEmitter1.Name = "Light"
- ParticleEmitter1.Parent = blade
- ParticleEmitter1.Speed = NumberRange.new(0, 0)
- ParticleEmitter1.Color = ColorSequence.new(Color3.new(1, 1, 0),Color3.new(1, 1, 1))
- ParticleEmitter1.Enabled = false
- ParticleEmitter1.LightEmission = 3
- ParticleEmitter1.Texture = "http://www.roblox.com/asset/?id=243660373"
- ParticleEmitter1.Transparency = NumberSequence.new(0.5,0.5)
- ParticleEmitter1.Size = NumberSequence.new(3,3)
- ParticleEmitter1.EmissionDirection = Enum.NormalId.Front
- ParticleEmitter1.Lifetime = NumberRange.new(0.5, 0.5)
- ParticleEmitter1.Rate = 26
- -- variables
- local equipped = false
- local using = false
- local attack_id = 0
- local last_attack = 0
- local last_equip = 0
- local last_block = 0
- local block_id = 0
- local using_block = false
- local holding_block = false
- local uid = 0
- --
- function get_uid()
- uid += 1
- return uid
- 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/20)
- 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
- local anim_speed = 1
- data.anim:Play(data.fade, anim_speed, 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 hit_data = {
- st = 0,
- dur = 0,
- func = nil,
- hit = {},
- }
- function hitbox(dur,func)
- hit_data = {
- st = os.clock(),
- dur = dur,
- func = func,
- hit = {},
- }
- end
- function stun(thum,n)
- local st = os.clock()
- thum:SetAttribute('stunned',st)
- task.delay(n,function()
- if thum:GetAttribute('stunned') == st then
- thum:SetAttribute('stunned',nil)
- end
- end)
- end
- function dmg_bypass(h,n)
- local int = Instance.new("NumberValue")
- int.Name = 'dmg_bypass'
- int.Value = n
- int.Parent = h
- hum:TakeDamage(n)
- end
- function dmg(targchar,n)
- local targhum = targchar:FindFirstChildOfClass("Humanoid")
- if targchar and targhum then
- local block = targhum:GetAttribute('block')
- local attack = targhum:GetAttribute('attack_blade')
- if attack then
- blade.Light:Emit(2)
- blade.Sparks:Emit(25)
- play_sound(blade,6331311995,0.5,math.random(95,105)/100)
- stun(targhum,0.8)
- stun(hum,0.8)
- targhum:SetAttribute('attack_blade',nil)
- hum:SetAttribute('attack_blade',nil)
- else
- targhum:TakeDamage(n)
- if block then
- if 0.3 >= os.clock()-block then -- parry
- dmg_bypass(hum,n*0.5)
- stun(hum,1.2)
- hum:SetAttribute('attack_blade',nil)
- else -- block
- end
- blade.Light:Emit(2)
- blade.Sparks:Emit(25)
- else
- local s = {4307102517,4307103510,4307103239,4307102878}
- play_sound(blade,s[attack_id],0.6,1)
- end
- end
- end
- end
- function m1(press)
- if equipped then else
- return
- end
- if not using then else
- return
- end
- if press then
- if hum:GetAttribute('stunned') then
- return
- end
- get_uid()
- using = true
- hum:SetAttribute('attack_blade',true)
- attack_id += 1
- if attack_id > 4 then
- attack_id = 1
- end
- local swing = load(anims['attack' .. attack_id])
- swing:Play(0.1)
- local s = {4085939047,3755636152,3755635916,3755635916}
- play_sound(blade,s[attack_id],0.5,1)
- task.delay(0.2,function()
- hitbox(swing.TimeLength-0.6,function(targchar,targroot,obj)
- dmg(targchar,25)
- end)
- end)
- task.delay(swing.TimeLength-0.25,function()
- using = false
- hum:SetAttribute('attack_blade',nil)
- end)
- end
- end
- function equip(press)
- if not using then else
- return
- end
- if os.clock()-last_equip >= 0.3 then else
- return
- end
- if press then
- if not equipped and not sprinting then
- equipped = true
- get_uid()
- using = true
- local equip = load(anims.equip)
- equip:Play()
- equip.MarkerReached:Connect(function(name) -- MarkerReached
- if name == 'SwitchHandle' then
- play_sound(blade,5752235534,0.5,1)
- blade.Color = Color3.new(1,0,0)
- blade.Material = Enum.Material.Neon
- w.C1 = CFrame.new(0,-1.6,1.1)*CFrame.Angles(math.rad(90),0,0)
- game:GetService("TweenService"):Create(blade,TweenInfo.new(0.3),{
- Transparency = 0
- }):Play()
- end
- end)
- task.delay(equip.TimeLength-0.3,function()
- last_equip = os.clock()
- using = false
- end)
- elseif equipped then
- equipped = false
- get_uid()
- using = true
- local equip = load(anims.unequip)
- equip:Play()
- equip.MarkerReached:Connect(function(name) -- MarkerReached
- if name == 'PlaySound' then
- play_sound(blade,4085939047,0.5,1)
- delay(0.77,function()
- game:GetService("TweenService"):Create(w,TweenInfo.new(0.2),{
- C1 = CFrame.new(0,1.6,1.1)*CFrame.Angles(math.rad(90),0,0)
- }):Play()
- end)
- elseif name == 'SwitchHandle' then
- play_sound(blade,3755634435,0.5,1)
- blade.Color = Color3.new(1,0,0)
- blade.Material = Enum.Material.Neon
- game:GetService("TweenService"):Create(blade,TweenInfo.new(0.3),{
- Transparency = 1
- }):Play()
- end
- end)
- task.delay(equip.TimeLength-0.2,function()
- last_equip = os.clock()
- using = false
- end)
- end
- end
- end
- local lhp = hum.Health
- hum.HealthChanged:Connect(function(nhp)
- if lhp > nhp and lhp > 0 then
- if hum:GetAttribute('block') then
- using_block = true
- local bypass = false
- for i,v in pairs(hum:GetChildren()) do
- if v.Name == 'dmg_bypass' and v.Value == lhp-nhp then
- bypass = true
- v:Destroy()
- break
- end
- end
- local block = hum:GetAttribute('block')
- block_id += 1
- if block_id > 4 then
- block_id = 1
- end
- blade.Light:Emit(2)
- blade.Sparks:Emit(25)
- hum:SetAttribute('block',os.clock()) -- reset block
- if 0.3 >= os.clock()-block or bypass then
- lhp = lhp + (lhp-nhp)*0.2
- hum.Health = lhp
- play_sound(blade,6331618544,0.5,math.random(95,105)/100)
- else
- local m = (os.clock()-block-0.3)/2
- m = math.clamp(m,0,0.5)
- lhp = lhp - (lhp-nhp)*m
- hum.Health = lhp
- local s = {3744369672,3744369932,3744370206,3932476666}
- play_sound(blade,s[block_id],0.8,1)
- end
- local anim = load(anims['block' .. block_id])
- anim:Play()
- local cid = get_uid()
- task.delay(anim.TimeLength-0.4,function()
- if not holding_block and uid == cid then
- using = false
- end
- using_block = false
- end)
- end
- end
- lhp = hum.Health
- end)
- function update_block()
- if not holding_block or hum:GetAttribute('stunned') then
- local anim = load(anims.block)
- if using_block then
- was_using_block = true
- end
- if (not using_block or hum:GetAttribute('stunned')) and anim.Playing then
- if os.clock()-last_block >= 0.2 then else
- return
- end
- using = false
- anim:Stop()
- hum:SetAttribute('block',nil)
- if not was_using_block then
- last_block = os.clock()
- end
- was_using_block = false
- end
- elseif holding_block then
- if not using then
- get_uid()
- using = true
- local anim = load(anims.block)
- anim:Play(0.1)
- hum:SetAttribute('block',os.clock())
- end
- end
- end
- function m2(press)
- if equipped then else
- return
- end
- if press then
- holding_block = true
- else
- holding_block = false
- end
- update_block()
- end
- function sprint(press)
- if press then
- sprinting = true
- else
- sprinting = false
- end
- end
- local keys = {
- [Enum.UserInputType.MouseButton1] = m1,
- [Enum.UserInputType.MouseButton2] = m2,
- [Enum.KeyCode.E] = equip,
- [Enum.KeyCode.LeftControl] = sprint,
- }
- local remote = Instance.new("RemoteEvent")
- remote.Parent = char
- remote.OnServerEvent:Connect(function(lplr,mode,data)
- if lplr == plr then
- if mode == 1 then
- if keys[data.key] then
- keys[data.key](data.press)
- end
- elseif mode == 2 then
- if hit_data.dur >= os.clock()-hit_data.st then
- for i,v in pairs(data) do
- if not hit_data.hit[v[1]] and 15 >= (root.Position-v[2].Position).Magnitude then else
- continue
- end
- hit_data.hit[v[1]] = true
- hit_data.func(unpack(v))
- end
- end
- end
- end
- end)
- NLS([[
- local remote = script.Parent
- local plr = game:GetService("Players").LocalPlayer
- local char = plr.Character
- local hum = char:FindFirstChildOfClass("Humanoid")
- local blade = char:WaitForChild("blade")
- local mouse = plr:GetMouse()
- local uis = game:GetService("UserInputService")
- uis.InputBegan:Connect(function(input,press)
- if not press then else return end
- local data = {press = true}
- if input.UserInputType == Enum.UserInputType.Keyboard then
- data.key = input.KeyCode
- elseif input.UserInputType == Enum.UserInputType.MouseButton1 then
- data.key = Enum.UserInputType.MouseButton1
- elseif input.UserInputType == Enum.UserInputType.MouseButton2 then
- data.key = Enum.UserInputType.MouseButton2
- end
- remote:FireServer(1,data)
- end)
- uis.InputEnded:Connect(function(input,press)
- local data = {press = false}
- if input.UserInputType == Enum.UserInputType.Keyboard then
- data.key = input.KeyCode
- elseif input.UserInputType == Enum.UserInputType.MouseButton1 then
- data.key = Enum.UserInputType.MouseButton1
- elseif input.UserInputType == Enum.UserInputType.MouseButton2 then
- data.key = Enum.UserInputType.MouseButton2
- end
- remote:FireServer(1,data)
- end)
- local hit = {}
- local last_fire = 0
- while true do
- if char and blade and hum and hum.Health > 0 then else
- break
- end
- local limbs = {blade}
- local params = OverlapParams.new()
- params.FilterDescendantsInstances = {char,junk}
- params.FilterType = Enum.RaycastFilterType.Blacklist
- params.MaxParts = 100
- for _,hitpart in ipairs(limbs) do
- for _,obj in ipairs(workspace:GetPartsInPart(hitpart,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}
- end
- end
- end
- if os.clock()-last_fire >= 0.1 then
- remote:FireServer(2,hit)
- last_fire = os.clock()
- hit = {}
- end
- game:GetService("RunService").RenderStepped:Wait()
- end
- ]],remote)
- --
- print([[
- Dynasty Battlegrounds: Bootleg
- -- stuff is still unfinished
- LMB = swing
- RMB = block
- E = equip
- CTRL = sprint
- ]])
- 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
- update_block()
- local idle = load(anims.idle)
- if equipped and not idle.Playing then
- idle:Play(0.1)
- elseif not equipped and idle.Playing then
- idle:Stop()
- 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
- local run = load(anims.run)
- local run_hold = load(anims.run_hold)
- if sprinting and current_move == 'walk' then
- if not equipped and not run.Playing then
- run:Play(0.2)
- run_hold:Play(0.2)
- hum.WalkSpeed = 16*1.3
- end
- else
- if run.Playing then
- run:Stop()
- run_hold:Stop()
- hum.WalkSpeed = 16
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement