Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- wait (1)
- local Player = game.Players.localPlayer
- local Character = Player.Character
- local Humanoid = Character.Humanoid
- local Mouse = Player:GetMouse()
- local LeftArm = Character["Left Arm"]
- local RightArm = Character["Right Arm"]
- local LeftLeg = Character["Left Leg"]
- local RightLeg = Character["Right Leg"]
- local Head = Character.Head
- local Torso = Character.Torso
- local Camera = game.Workspace.CurrentCamera
- local RootPart = Character.HumanoidRootPart
- local RootJoint = RootPart.RootJoint
- local attack = false
- local Anim = 'Idle'
- local attacktype = 1
- local delays = false
- local play = true
- local targetted = nil
- local Torsovelocity = (RootPart.Velocity * Vector3.new(1, 0, 1)).magnitude
- local velocity = RootPart.Velocity.y
- local sine = 0
- local change = 1
- local doe = 0
- local Create = LoadLibrary("RbxUtility").Create
- P=Instance.new("ForceField", game.Players.LocalPlayer.Character)
- P.Visible = false
- local Lighty = game:GetService"Lighting"
- local Sitting = false
- local idleC = 0
- local m = Create("Model"){
- Parent = Character,
- Name = "WeaponModel",
- }
- spawn(function()
- Character.Humanoid.MaxHealth = math.huge
- Character.Humanoid.Health = math.huge
- while wait() do
- Head.BrickColor = BrickColor.new("Bright yellow")
- RightArm.BrickColor = BrickColor.new("Bright yellow")
- LeftArm.BrickColor = BrickColor.new("Bright yellow")
- Torso.BrickColor = BrickColor.new("Bright blue")
- RightLeg.BrickColor = BrickColor.new("Shamrock")
- LeftLeg.BrickColor = BrickColor.new("Shamrock")
- end
- end)
- for i,v in pairs(Character:children()) do
- if v:IsA("Accessory") then
- v:Destroy()
- end
- end
- for i,v in pairs(Character:children()) do
- if v:IsA("Shirt") then
- v:Destroy()
- end
- end
- for i,v in pairs(Character:children()) do
- if v:IsA("Pants") then
- v:Destroy()
- end
- end
- for i,v in pairs(Character:children()) do
- if v:IsA("Graphic Shirt") then
- v:Destroy()
- end
- end
- 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
- -- ANIMATION
- -- declarations
- local Figure = script.Parent
- local Torso = waitForChild(Figure, "Torso")
- 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
- local jumpMaxLimbVelocity = 0.75
- -- 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 onSwimming(speed)
- if speed>0 then
- pose = "Running"
- else
- pose = "Standing"
- end
- end
- function moveJump()
- RightShoulder.MaxVelocity = jumpMaxLimbVelocity
- LeftShoulder.MaxVelocity = jumpMaxLimbVelocity
- RightShoulder:SetDesiredAngle(3.14)
- LeftShoulder:SetDesiredAngle(-3.14)
- RightHip:SetDesiredAngle(0)
- LeftHip:SetDesiredAngle(0)
- end
- -- same as jump for now
- function moveFreeFall()
- RightShoulder.MaxVelocity = jumpMaxLimbVelocity
- LeftShoulder.MaxVelocity = jumpMaxLimbVelocity
- RightShoulder:SetDesiredAngle(3.14)
- LeftShoulder:SetDesiredAngle(-3.14)
- RightHip:SetDesiredAngle(0)
- LeftHip:SetDesiredAngle(0)
- end
- function moveSit()
- RightShoulder.MaxVelocity = 0.15
- LeftShoulder.MaxVelocity = 0.15
- RightShoulder:SetDesiredAngle(3.14 /2)
- LeftShoulder:SetDesiredAngle(-3.14 /2)
- RightHip:SetDesiredAngle(3.14 /2)
- LeftHip:SetDesiredAngle(-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:SetDesiredAngle(1.57)
- return
- end
- if (toolAnim == "Slash") then
- RightShoulder.MaxVelocity = 0.5
- RightShoulder:SetDesiredAngle(0)
- return
- end
- if (toolAnim == "Lunge") then
- RightShoulder.MaxVelocity = 0.5
- LeftShoulder.MaxVelocity = 0.5
- RightHip.MaxVelocity = 0.5
- LeftHip.MaxVelocity = 0.5
- RightShoulder:SetDesiredAngle(1.57)
- LeftShoulder:SetDesiredAngle(1.0)
- RightHip:SetDesiredAngle(1.57)
- LeftHip:SetDesiredAngle(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
- if (RightShoulder.CurrentAngle > 1.5 or RightShoulder.CurrentAngle < -1.5) then
- RightShoulder.MaxVelocity = jumpMaxLimbVelocity
- else
- RightShoulder.MaxVelocity = 0.15
- end
- if (LeftShoulder.CurrentAngle > 1.5 or LeftShoulder.CurrentAngle < -1.5) then
- LeftShoulder.MaxVelocity = jumpMaxLimbVelocity
- else
- LeftShoulder.MaxVelocity = 0.15
- end
- 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:SetDesiredAngle(desiredAngle + climbFudge)
- LeftShoulder:SetDesiredAngle(desiredAngle - climbFudge)
- RightHip:SetDesiredAngle(-desiredAngle)
- LeftHip:SetDesiredAngle(-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)
- Humanoid.Swimming:connect(onSwimming)
- -- main program
- print("Finding player... (This may take a little!)")
- wait (1)
- print("Found player. Now giving the sword.")
- local user = game.Players.LocalPlayer.Backpack
- local sword = Instance.new("Tool",user)
- print("Gave the player the sword. Enjoy!")
- local handle = Instance.new("Part",sword)
- local mesh = Instance.new("SpecialMesh",handle)
- local DAMAGE = 35
- local sound = Instance.new("Sound",handle)
- local sound2 = Instance.new("Sound",handle)
- sword.Name = "Sword"
- script.Parent = sword
- script.Name = "SwordScript"
- --local animation = Instance.new("Animation",script)
- --animation.AnimationId = "http://www.roblox.com/Asset?ID=992817684"
- sound.SoundId = "rbxasset://sounds//swordlunge.wav"
- sound.Volume = 3
- sound.PlaybackSpeed = 1.17
- sound.Name = "Slash"
- sound2.SoundId = "rbxasset://sounds//unsheath.wav"
- sound2.Volume = 3
- sound2.PlaybackSpeed = 0.8
- sound2.Volume = 3
- sound2.Name = "Unsheath"
- function unsheathanimation()
- sword.GripPos = sword.GripPos + Vector3.new(0,5,0)
- for i = 1,5 do
- sword.GripPos = sword.GripPos + Vector3.new(0,-1,0)
- wait (0.1)
- end
- end
- function unsheathsound()
- sound2:Play()
- end
- function damage(hit)
- local h = hit.Parent:FindFirstChild("Humanoid")
- if (h ~= nil) then
- h:TakeDamage(DAMAGE / 4)
- end
- end
- function animate()
- --4
- sound:Play()
- for i = 1,5 do
- sword.GripUp = sword.GripUp + Vector3.new(0,0,1)
- wait (0)
- end
- sword.GripUp = sword.GripUp + Vector3.new(0,0,-1)
- end
- handle.Size = handle.Size + Vector3.new(-4,-1,-2)
- handle.Size = handle.Size + Vector3.new(0.6, 3.6, 0.4)
- handle.Name = "Handle"
- mesh.MeshType = "FileMesh"
- mesh.MeshId = "http://www.roblox.com/asset/?id=94746028"
- mesh.TextureId = "http://www.roblox.com/asset/?ID=94746105"
- mesh.Offset = mesh.Offset + Vector3.new(0,1,0)
- sword.Equipped:connect(unsheathanimation)
- sword.Equipped:connect(unsheathsound)
- wait(sound2.TimeLength)
- sword.Activated:connect(animate)
- handle.Touched:connect(damage)
- local runService = game:service("RunService");
- while Figure.Parent~=nil do
- local _, time = wait(0.1)
- move(time)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement