null nil 0 true 0 0 0 1 0 0 0 1 0 0 0 1 AI null true false -0.5 0.5 0 0 -0.5 0.5 4 0 24 21 6.9000001 -28.5 -1 0 0 0 1 0 0 0 -1 true 0 true false 0.5 0 0.300000012 -0.5 0.5 0 0 -0.5 0.5 0 0 false Head 0 -0.5 0.5 0 0 0 0 0 -0.5 0.5 0 0 0 0 0 0 true 1 2 1 1 2 2 0 Mesh 0 0 0 1.25 1.25 1.25 1 1 1 true 5 face 20 0 rbxasset://textures\face.png true 0 0.5 0 1 0 0 0 1 0 0 0 1 0 -0.170000002 0 1 0 0 0 1 0 0 0 1 HeadWeld null null true 0 0.5 0 1 0 0 0 1 0 0 0 1 0 -0.170000002 0 1 0 0 0 1 0 0 0 1 HeadWeld null null true 0 0.5 0 1 0 0 0 1 0 0 0 1 0 0.400000006 0.0799999982 1 0 0 0 1 0 0 0 1 HeadWeld null null true false -0.5 0.5 0 0 -0.5 0.5 4 0 1 21 5.4000001 -28.5 -1 0 -0 -0 1 -0 -0 0 -1 true 0 true false 0.5 0 0.300000012 -0.5 0.5 0 0 0 0 2 0 false Torso 0 0 0 2 0 0 0 0 -0.5 0.5 3 0 0 0 0 0 true 1 2 2 1 5 roblox 20 0 iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAALHRFWHRDcmVhdGlvbiBUaW1l AE1vbiAyMSBBcHIgMjAwOCAxNjo0NDo0OCAtMDgwMMFcEAAAAAAHdElNRQfYBBUXLQp5aDOL AAAACXBIWXMAAAsSAAALEgHS3X78AAAABGdBTUEAALGPC/xhBQAAABJJREFUeNpjYBgFo2AU jAIIAAAEEAABr0WILAAAAABJRU5ErkJggg== true false -0.5 0.5 0 0 -0.5 0.5 4 0 24 22.5 5.4000001 -28.5 -1 0 0 0 1 0 0 0 -1 false 0 true false 0.5 0 0.300000012 -0.5 0.5 0 0 -0.5 0.5 0 0 false Left Arm 0 -0.5 0.5 0 0 0 0 0 -0.5 0.5 3 0 0 0 0 0 true 1 1 2 1 false -0.5 0.5 0 0 -0.5 0.5 4 0 24 19.5 5.4000001 -28.5 -1 0 0 0 1 0 0 0 -1 false 0 true false 0.5 0 0.300000012 -0.5 0.5 0 0 -0.5 0.5 0 0 false Right Arm 0 -0.5 0.5 0 0 0 0 0 -0.5 0.5 3 0 0 0 0 0 true 1 1 2 1 false -0.5 0.5 0 0 -0.5 0.5 0 0 119 21.5 3.4000001 -28.5 -1 0 0 0 1 0 0 0 -1 false 0 true false 0.5 0 0.300000012 -0.5 0.5 0 0 -0.5 0.5 0 0 false Left Leg 0 -0.5 0.5 0 0 0 0 0 -0.5 0.5 3 0 0 0 0 0 true 1 1 2 1 false -0.5 0.5 0 0 -0.5 0.5 0 0 119 20.5 3.4000001 -28.5 -1 0 0 0 1 0 0 0 -1 false 0 true false 0.5 0 0.300000012 -0.5 0.5 0 0 -0.5 0.5 0 0 false Right Leg 0 -0.5 0.5 0 0 0 0 0 -0.5 0.5 3 0 0 0 0 0 true 1 1 2 1 100 false 450 Humanoid false false 0 0 0 0 0 0 0 16 null 0 0 0 true false Script script.Parent.MaxHealth = 450 script.Parent.Health = 450 true false Script local Model = script.Parent local Backup = Model:clone() function Respawn() Model:breakJoints() wait(5) script.Parent = Model.Parent Model:remove() Model = Backup:clone() Model.Parent = script.Parent Model:makeJoints() script:remove() end Model.Humanoid.Died:connect(Respawn) function waitForChild(parent, childName) local child = parent:findFirstChild(childName) if child then return child end while true do print(childName) child = parent.ChildAdded:wait() if child.Name==childName then return child end end end -- declarations local Figure = script.Parent local Head = waitForChild(Figure, "Head") local Humanoid = waitForChild(Figure, "Humanoid") Figure.PrimaryPart = Head -- ANIMATION function Joint(Name, Part0, Part1, C0, C1, MaxVelocity) local Motor = Instance.new("Motor") Motor.C0 = C0 Motor.C1 = C1 Motor.MaxVelocity = MaxVelocity Motor.Name = Name Motor.Parent = Part0 Motor.Part0 = Part0 Motor.Part1 = Part1 end -- declarations local Torso = waitForChild(Figure, "Torso") local LeftArm = waitForChild(Figure, "Left Arm") local LeftLeg = waitForChild(Figure, "Left Leg") local RightArm = waitForChild(Figure, "Right Arm") local RightLeg = waitForChild(Figure, "Right Leg") local Joints = { {"Right Shoulder", Torso, RightArm, CFrame.new(1, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0), CFrame.new(-0.5, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0), 0.5}, {"Left Shoulder", Torso, LeftArm, CFrame.new(-1, 0.5, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0), CFrame.new(0.5, 0.5, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0), 0.5}, {"Right Hip", Torso, RightLeg, CFrame.new(1, -1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0), CFrame.new(0.5, 1, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0), 0.10000000149012}, {"Left Hip", Torso, LeftLeg, CFrame.new(-1, -1, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0), CFrame.new(-0.5, 1, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0), 0.10000000149012}, {"Neck", Torso, Head, CFrame.new(0, 1, 0, -1, -0, -0, 0, 0, 1, 0, 1, 0), CFrame.new(0, -0.5, 0, -1, -0, -0, 0, 0, 1, 0, 1, 0), 0.10000000149012}} Torso:breakJoints() for _, v in pairs(Joints) do Joint(unpack(v)) end local RightShoulder = waitForChild(Torso, "Right Shoulder") local LeftShoulder = waitForChild(Torso, "Left Shoulder") local RightHip = waitForChild(Torso, "Right Hip") local LeftHip = waitForChild(Torso, "Left Hip") local Neck = waitForChild(Torso, "Neck") local Humanoid = waitForChild(Figure, "Humanoid") local pose = "Standing" local toolAnim = "None" local toolAnimTime = 0 -- functions function onRunning(speed) if speed>0 then pose = "Running" else pose = "Standing" end end function onDied() pose = "Dead" end function onJumping() pose = "Jumping" end function onClimbing() pose = "Climbing" end function onGettingUp() pose = "GettingUp" end function onFreeFall() pose = "FreeFall" end function onFallingDown() pose = "FallingDown" end function onSeated() pose = "Seated" end function onPlatformStanding() pose = "PlatformStanding" end function moveJump() RightShoulder.MaxVelocity = 0.5 LeftShoulder.MaxVelocity = 0.5 RightShoulder.DesiredAngle = 3.14 LeftShoulder.DesiredAngle = -3.14 RightHip.DesiredAngle = 0 LeftHip.DesiredAngle = 0 end -- same as jump for now function moveFreeFall() RightShoulder.MaxVelocity = 0.5 LeftShoulder.MaxVelocity = 0.5 RightShoulder.DesiredAngle = 3.14 LeftShoulder.DesiredAngle = -3.14 RightHip.DesiredAngle = 0 LeftHip.DesiredAngle = 0 end function moveSit() RightShoulder.MaxVelocity = 0.15 LeftShoulder.MaxVelocity = 0.15 RightShoulder.DesiredAngle = 3.14 /2 LeftShoulder.DesiredAngle = -3.14 /2 RightHip.DesiredAngle = 3.14 /2 LeftHip.DesiredAngle = -3.14 /2 end function getTool() for _, kid in ipairs(Figure:GetChildren()) do if kid.className == "Tool" then return kid end end return nil end function getToolAnim(tool) for _, c in ipairs(tool:GetChildren()) do if c.Name == "toolanim" and c.className == "StringValue" then return c end end return nil end function animateTool() if (toolAnim == "None") then RightShoulder.DesiredAngle = 1.57 return end if (toolAnim == "Slash") then RightShoulder.MaxVelocity = 0.5 RightShoulder.DesiredAngle = 0 return end if (toolAnim == "Lunge") then RightShoulder.MaxVelocity = 0.5 LeftShoulder.MaxVelocity = 0.5 RightHip.MaxVelocity = 0.5 LeftHip.MaxVelocity = 0.5 RightShoulder.DesiredAngle = 1.57 LeftShoulder.DesiredAngle = 1.0 RightHip.DesiredAngle = 1.57 LeftHip.DesiredAngle = 1.0 return end end function move(time) local amplitude local frequency if (pose == "Jumping") then moveJump() return end if (pose == "FreeFall") then moveFreeFall() return end if (pose == "Seated") then moveSit() return end local climbFudge = 0 if (pose == "Running") then RightShoulder.MaxVelocity = 0.15 LeftShoulder.MaxVelocity = 0.15 amplitude = 1 frequency = 9 elseif (pose == "Climbing") then RightShoulder.MaxVelocity = 0.5 LeftShoulder.MaxVelocity = 0.5 amplitude = 1 frequency = 9 climbFudge = 3.14 else amplitude = 0.1 frequency = 1 end desiredAngle = amplitude * math.sin(time*frequency) RightShoulder.DesiredAngle = desiredAngle + climbFudge LeftShoulder.DesiredAngle = desiredAngle - climbFudge RightHip.DesiredAngle = -desiredAngle LeftHip.DesiredAngle = -desiredAngle local tool = getTool() if tool then animStringValueObject = getToolAnim(tool) if animStringValueObject then toolAnim = animStringValueObject.Value -- message recieved, delete StringValue animStringValueObject.Parent = nil toolAnimTime = time + .3 end if time > toolAnimTime then toolAnimTime = 0 toolAnim = "None" end animateTool() else toolAnim = "None" toolAnimTime = 0 end end -- connect events Humanoid.Died:connect(onDied) Humanoid.Running:connect(onRunning) Humanoid.Jumping:connect(onJumping) Humanoid.Climbing:connect(onClimbing) Humanoid.GettingUp:connect(onGettingUp) Humanoid.FreeFalling:connect(onFreeFall) Humanoid.FallingDown:connect(onFallingDown) Humanoid.Seated:connect(onSeated) Humanoid.PlatformStanding:connect(onPlatformStanding) -- util function waitForChild(parent, childName) local child = parent:findFirstChild(childName) if child then return child end while true do child = parent.ChildAdded:wait() if child.Name==childName then return child end end end function newSound(id) local sound = Instance.new("Sound") sound.SoundId = id sound.archivable = false sound.Parent = script.Parent.Head return sound end -- declarations local sDied = newSound("rbxasset://sounds/uuhhh.wav") local sFallingDown = newSound("rbxasset://sounds/splat.wav") local sFreeFalling = newSound("rbxasset://sounds/swoosh.wav") local sGettingUp = newSound("rbxasset://sounds/hit.wav") local sJumping = newSound("rbxasset://sounds/button.wav") local sRunning = newSound("rbxasset://sounds/bfsl-minifigfoots1.mp3") sRunning.Looped = true -- functions function onSoundDied() sDied:Play() end function onState(state, sound) if state then sound:Play() else sound:Pause() end end function onSoundRunning(speed) if speed>0 then sRunning:Play() else sRunning:Pause() end end -- connect up Humanoid.Died:connect(onSoundDied) Humanoid.Running:connect(onSoundRunning) Humanoid.Jumping:connect(function(state) onState(state, sJumping) end) Humanoid.GettingUp:connect(function(state) onState(state, sGettingUp) end) Humanoid.FreeFalling:connect(function(state) onState(state, sFreeFalling) end) Humanoid.FallingDown:connect(function(state) onState(state, sFallingDown) end) local runService = game:service("RunService"); delay(0, function() while Figure.Parent~=nil do local _, time = wait(0.1) move(time) end end) -- regeneration while true do local s = wait(1) local health = Humanoid.Health if health > 0 and health < Humanoid.MaxHealth then health = health + 0.01 * s * Humanoid.MaxHealth if health * 1.05 < Humanoid.MaxHealth then Humanoid.Health = health else Humanoid.Health = Humanoid.MaxHealth end end end true 0 4 true 0 0 -1.5 0 0 1 1 0 0 0 1 0 ClassicSword rbxasset://Textures\Sword128.png true false Swordscript r = game:service("RunService") local damage = 7.5 local slash_damage = 15 local lunge_damage = 50 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 jump(human) if human == nil then return; end local torso = human:FindFirstChild("Torso"); if torso == nil then return; end counter = 0 while counter < 5 do counter = counter + 1 local bav = Instance.new("BodyAngularVelocity"); bodyAngularVelocity = bav; bav.maxTorque = Vector3.new(1e+009, 1e+009, 1e+009); bav.angularvelocity = Vector3.new(0,math.random(-10.5,10.5),0); bav.Parent = torso; wait(0.1) bav:remove() end end function blow(hit) if (hit.Parent == nil) then return end -- happens when bullet hits sword 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.Health = humanoid.Health - 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(.25) swordOut() wait(.25) 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 character = nil Tool.Enabled = true local last_attack = 0 function onActivated() if not Tool.Enabled then return end Tool.Enabled = false 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 onEquipped() connection = sword.Touched:connect(blow) function jumpreal(chr) coroutine.resume(coroutine.create(function() jump(chr) end)) end while true do wait(0.5) if script.Parent.Parent.CanAttack.Value == true then onActivated() jumpreal(character) wait(0.5) onActivated() jumpreal(character) wait(0.1) onActivated() jumpreal(character) end end true false -0.5 0.5 0 0 -0.5 0.5 0 0 199 21 5.20000029 -26.5 0 0 -1 0 1 -0 1 0 -0 true 0 true false 0.5 2 0.300000012 -0.5 0.5 0 0 -0.5 0.5 0 0 false Handle 0.400000006 -0.5 0.5 0 0 0 0 0 -0.5 0.5 0 0 0 0 0 0 true 1 1 0.800000012 4 2 2 rbxasset://fonts/sword.mesh 5 Mesh 0 0 0 1 1 1 rbxasset://textures/SwordTexture.png 1 1 1 true false Local Gui local Tool = script.Parent; enabled = true function onButton1Down(mouse) if not enabled then return end enabled = false mouse.Icon = "rbxasset://textures\\GunWaitCursor.png" wait(.5) mouse.Icon = "rbxasset://textures\\GunCursor.png" enabled = true end function onEquippedLocal(mouse) if mouse == nil then print("Mouse not found") return end mouse.Icon = "rbxasset://textures\\GunCursor.png" mouse.Button1Down:connect(function() onButton1Down(mouse) end) end Tool.Equipped:connect(onEquippedLocal) true false AI function findNearestTorso(pos) local list = game.Workspace:children() local torso = nil local dist = 100 local temp = nil local human = nil local temp2 = nil for x = 1, #list do temp2 = list[x] if (temp2.className == "Model") and (temp2 ~= script.Parent) then human = temp2:findFirstChild("Humanoid") temp = temp2:findFirstChild("Torso") if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then if (temp.Position - pos).magnitude < dist then torso = temp dist = (temp.Position - pos).magnitude end end end end return torso end while true do wait(math.random(0.2,0.3)) local target = findNearestTorso(script.Parent.Torso.Position) if target ~= nil then script.Parent.Humanoid:MoveTo(target.Position, target) print((target.Position - script.Parent.Torso.Position).magnitude) if (target.Position - script.Parent.Torso.Position).magnitude < 10 and target.Parent.Humanoid.Health > 0 and script.Parent.Humanoid.Health > 0 then script.Parent.CanAttack.Value = true else script.Parent.CanAttack.Value = false end else script.Parent.CanAttack.Value = false end end true CanAttack false true