Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function sandbox(var,func)
- local env = getfenv(func)
- local newenv = setmetatable({},{
- __index = function(self,k)
- if k=="script" then
- return var
- else
- return env[k]
- end
- end,
- })
- setfenv(func,newenv)
- return func
- end
- cors = {}
- mas = Instance.new("Model",game:GetService("Lighting"))
- Tool0 = Instance.new("Tool")
- Part1 = Instance.new("Part")
- Fire2 = Instance.new("Fire")
- SpecialMesh3 = Instance.new("SpecialMesh")
- Weld4 = Instance.new("Weld")
- Sound5 = Instance.new("Sound")
- Sound6 = Instance.new("Sound")
- Sound7 = Instance.new("Sound")
- Sparkles8 = Instance.new("Sparkles")
- LocalScript9 = Instance.new("LocalScript")
- Script10 = Instance.new("Script")
- LocalScript11 = Instance.new("LocalScript")
- Script12 = Instance.new("Script")
- Tool0.Name = "Card"
- Tool0.Parent = mas
- Tool0.Grip = CFrame.new(0, 0.731632411, 0.429803371, 1, 0, 0, 0, -0.0654020309, 0.997859001, 0, -0.997859001, -0.0654020309)
- Tool0.GripForward = Vector3.new(-0, -0.997859001, 0.0654020309)
- Tool0.GripPos = Vector3.new(0, 0.731632411, 0.429803371)
- Tool0.GripUp = Vector3.new(0, -0.0654020309, -0.997859001)
- Part1.Name = "Handle"
- Part1.Parent = Tool0
- Part1.CFrame = CFrame.new(-67.8400116, 1.6550045, 120.055, 1, 0, 0, 0, 1, 0, 0, 0, 1)
- Part1.Position = Vector3.new(-67.8400116, 1.6550045, 120.055)
- Part1.Color = Color3.new(1, 0, 0.74902)
- Part1.Size = Vector3.new(1.01999986, 1.31000006, 3.05000019)
- Part1.BottomSurface = Enum.SurfaceType.Smooth
- Part1.BrickColor = BrickColor.new("Hot pink")
- Part1.Material = Enum.Material.Neon
- Part1.TopSurface = Enum.SurfaceType.Smooth
- Part1.brickColor = BrickColor.new("Hot pink")
- Fire2.Parent = Part1
- Fire2.Color = Color3.new(0.345098, 0.0431373, 0.278431)
- Fire2.Heat = 0
- Fire2.SecondaryColor = Color3.new(0, 0, 0)
- SpecialMesh3.Parent = Part1
- SpecialMesh3.MeshId = "http://www.roblox.com/asset/?id=30694864"
- SpecialMesh3.Scale = Vector3.new(1, 1, 1.29999995)
- SpecialMesh3.MeshType = Enum.MeshType.FileMesh
- Weld4.Name = "HandleTipWeld"
- Weld4.Parent = Part1
- Weld4.C0 = CFrame.new(0, 2.79999995, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)
- Sound5.Name = "SwordLunge"
- Sound5.Parent = Part1
- Sound5.SoundId = "http://www.roblox.com/asset/?id=12222208"
- Sound5.Volume = 0.60000002384186
- Sound6.Name = "SwordSlash"
- Sound6.Parent = Part1
- Sound6.SoundId = "http://www.roblox.com/asset/?id=12222216"
- Sound6.Volume = 0.69999998807907
- Sound7.Name = "Unsheath"
- Sound7.Parent = Part1
- Sound7.SoundId = "http://www.roblox.com/asset/?id=12222225"
- Sound7.Volume = 1
- Sparkles8.Parent = Part1
- LocalScript9.Name = "Spear_Main"
- LocalScript9.Parent = Tool0
- table.insert(cors,sandbox(LocalScript9,function()
- --local mDebugId = game.Workspace.DebugId.Value
- --game.Workspace.DebugId.Value = game.Workspace.DebugId.Value+1
- --print("Running swordscript <"..mDebugId..">")
- -------------------------------------
- -- Makes an RBX::Lua Instance using
- -- a table of key-value pairs to
- -- initialize it. Values with numeric
- -- keys will be parented to the object
- -- and other values will be set
- -- as members of the object.
- function Create(ty)
- return function(data)
- local obj = Instance.new(ty)
- for k, v in pairs(data) do
- if type(k) == 'number' then
- v.Parent = obj
- else
- obj[k] = v
- end
- end
- return obj
- end
- end
- ---------------------------------------
- -- Same as Make, but modifies an existing
- -- object rather than creating ones.
- function Modify(obj, data)
- for k, v in pairs(data) do
- if type(data) == 'number' then
- data.Parent = obj
- else
- data[k] = v
- end
- end
- return obj
- end
- -----------------------------------------
- -- Creates a class which can be instantiated
- -- using `CreateCLASSNAME( ... )`.
- ---usage:
- --class'MyClass'(function(this, arg1)
- -- this.ClassMember = value
- -- function this.ClassMethod(...) ... end
- --end, function(def)
- -- def.StaticMember = value
- -- function def.StaticMethod(...) ... end
- --end)
- --local obj = CreateMyClass(arg1)
- ------------------------------------------
- local function class(name)
- local def = {}
- getfenv(0)[name] = def
- return function(ctor, static)
- local nctor = function(...)
- local this = {}
- if ctor then
- ctor(this, ...)
- end
- return this
- end
- getfenv(0)['Create'..name] = nctor
- if static then static(def) end
- end
- end
- ---------------------------------------------
- -- Signal class for custom-made events
- --API:
- -- Signal:connect(callback)
- -- Signal:fire(...)
- -- Signal:wait()
- ---------------------------------------------
- class'Signal'(function(this)
- local mListeners = {}
- local mWaitObject = Create'BoolValue'{}
- function this:connect(func)
- local connection = {}
- function connection:disconnect()
- mListeners[func] = nil
- end
- mListeners[func] = connection
- return connection
- end
- function this:fire(...)
- --print("Fire evt<"..tostring(this).."> from script<"..mDebugId..">")
- for func, conn in pairs(mListeners) do
- --print("-> "..tostring(func).."( ... )")
- func(...)
- end
- mWaitObject.Value = not mWaitObject.Value
- end
- function this:wait()
- mWaitObject.Changed:wait()
- end
- end)
- --------------------------------------------------
- -- Bin class for cleaning up assets
- --API:
- -- Bin:add(func: Function, ident: String)
- -- Bin:clean(ident: String)
- -- Bin:cleanAll()
- --------------------------------------------------
- class'Bin'(function(this)
- local mGarbage = {}
- function this:add(func, ident)
- ident = ident or '__unnamed'
- if not mGarbage[ident] then
- mGarbage[ident] = {}
- end
- mGarbage[ident][#mGarbage[ident]+1] = func
- end
- function this:clean(ident)
- local listToCall = mGarbage[ident]
- if listToCall then
- for _, func in pairs(listToCall) do
- func()
- end
- mGarbage[ident] = nil
- end
- end
- function this:cleanAll()
- for ident, list in pairs(mGarbage) do
- for _, func in pairs(list) do
- func()
- end
- mGarbage[ident] = nil
- end
- end
- end)
- -----------------------------------------------------
- -- AnimationProvider class for easy loading of
- -- animation assets into animationtracks once
- -- a humanoid is available.
- --API:
- -- AnimationProvider:registerAnimation(ident, assetid)
- -- AnimationProvider:setHumanoid(humanoid)
- -- AnimationProvider:setTool(tool)
- -- AnimationProvider:getAnimation(ident)
- -----------------------------------------------------
- class'AnimationProvider'(function(this)
- local mAnimations = {--[[ident => {AnimationId, CurrentTrack, CurrentAnim} ]]}
- local mCurrentHumanoid = nil
- function this:registerAnimation(ident, assetid)
- --check for an existing copy of the anim
- local existingAnim = Tool.Tool:FindFirstChild('ANIM_'..ident)
- --make the data for this anim
- local animdat = {
- AnimationId = assetid,
- CurrentAnim = existingAnim or Create'Animation'{
- Name = "ANIM_"..ident,
- AnimationId = assetid,
- },
- }
- mAnimations[ident] = animdat
- --if there's a current tool, put it in there
- if Tool.Tool then
- Tool.HUGE_EQUIP_HACK = true
- animdat.CurrentAnim.Parent = Tool.Tool
- Tool.HUGE_EQUIP_HACK = false
- end
- --if there's a humanoid load the animation track
- if mCurrentHumanoid then
- animdat.CurrentTrack = mCurrentHumanoid:LoadAnimation(animdat.CurrentAnim)
- end
- end
- function this:setHumanoid(humanoid)
- mCurrentHumanoid = humanoid
- for _, anim in pairs(mAnimations) do
- anim.CurrentTrack = humanoid:LoadAnimation(anim.CurrentAnim)
- end
- end
- function this:getAnimation(ident)
- local dat = mAnimations[ident]
- if not dat then error("Gear Fatal Error: Animation `"..ident.."` not found") end
- if not dat.CurrentTrack then
- error("Gear Fatal Error: No Humanoid for animation `"..ident.."` to run in")
- end
- return dat.CurrentTrack
- end
- end)
- ----------------------------------------------
- -- SoundProvider class
- -- functions similarily to the animationprovider
- ----------------------------------------------
- class'SoundProvider'(function(this)
- local mSounds = {}
- function this:registerSound(ident, assetid, inpart)
- inpart = inpart or Tool.Tool:FindFirstChild('Handle')
- if not inpart then
- repeat
- inpart = Tool.Tool.ChildAdded:wait()
- until inpart.Name == 'Handle'
- end
- local existingSound = inpart:FindFirstChild('SOUND_'..ident)
- local sounddat = {
- SoundId = assetid,
- CurrentSound = existingSound or Create'Sound'{
- Name = 'SOUND_'..ident,
- SoundId = assetid,
- Parent = inpart,
- },
- }
- mSounds[ident] = sounddat
- end
- function this:getSound(ident)
- local dat = mSounds[ident]
- if dat then
- return dat.CurrentSound
- end
- end
- end)
- ----------------------------------------------
- -- DebounceProvider class -- Prevent events
- -- from happening in too rapid succession
- ----------------------------------------------
- class'DebounceProvider'(function(this)
- local mFlagNameToLastTime = {}
- function this:test(ident, delta)
- local t = tick()
- local lastTime = mFlagNameToLastTime[ident] or 0
- if delta then
- return (t-lastTime) > delta
- else
- return mFlagNameToLastTime[ident]
- end
- end
- function this:set(ident, state)
- if state then
- mFlagNameToLastTime[ident] = state
- elseif state == false then
- mFlagNameToLastTime[ident] = false
- else
- mFlagNameToLastTime[ident] = tick()
- end
- end
- end)
- function TagHumanoid(humanoid)
- if Tool.Player then
- local tag = Create'ObjectValue'{
- Name = "creator",
- Value = Tool.Player,
- Parent = humanoid,
- }
- game.Debris:AddItem(tag, 1)
- end
- end
- ------- wait for any event in a set of events to fire ------
- function WaitForAny(tb)
- local evt = tb
- local conn = {}
- local eventargs = nil
- local waitProxy = Create'BoolValue'{}
- for _, e in pairs(evt) do
- local c = e:connect(function(...)
- for _, c in pairs(conn) do
- c:disconnect()
- end
- eventargs = {...}
- waitProxy.Value = not waitProxy.Value
- end)
- conn[#conn+1] = c
- end
- --
- waitProxy.Changed:wait()
- --
- return unpack(eventargs)
- end
- ----------------------------------------------
- -- Tool singleton class
- --API:
- -- ...
- class'Tool'(nil, function(this)
- --need this here for the animationprovider to use
- this.HUGE_EQUIP_HACK = false
- this.Bin = CreateBin()
- this.AnimationProvider = CreateAnimationProvider()
- this.DebounceProvider = CreateDebounceProvider()
- this.SoundProvider = CreateSoundProvider()
- --general values
- this.Tool = script.Parent
- this.Player = nil
- this.Humanoid = nil
- this.Character = nil
- --============ several flags for the gear
- --nothing
- --some events
- this.Equipped = CreateSignal()
- this.Unequipped = CreateSignal()
- this.OwnerChange = CreateSignal()
- --mouse utility events
- this.MouseClick = CreateSignal()
- this.MouseRelease = CreateSignal()
- this.MouseDoubleClick = CreateSignal()
- this.DoubleClickThreshold = 0.2
- this.MouseDown = false
- this.KeyDown = CreateSignal()
- local mLastClickTime = 0
- script.Parent.Equipped:connect(function(mouse)
- --print("Internal Equipped: Time b: "..time())
- --set up general values in the tool
- this.Mouse = mouse
- local curOwner = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
- if curOwner ~= this.Player then
- this.Player = curOwner
- this.OwnerChange:fire(this.Player)
- end
- this.Character = this.Player.Character
- this.Humanoid = this.Character.Humanoid
- this.AnimationProvider:setHumanoid(this.Humanoid)
- --set up the mouse events
- mouse.Button1Down:connect(function()
- this.MouseDown = true
- local t = tick()
- if (t-mLastClickTime) < this.DoubleClickThreshold then
- --prvent multiple double-clicks in a row
- mLastClickTime = 0
- this.MouseDoubleClick:fire(mouse)
- else
- mLastClickTime = t
- this.MouseClick:fire(mouse)
- end
- end)
- mouse.Button1Up:connect(function()
- this.MouseDown = false
- this.MouseRelease:fire()
- end)
- mouse.KeyDown:connect(function(key)
- this.KeyDown:fire(key)
- end)
- --done setup, call the equipped function
- if this.HUGE_EQUIP_HACK then
- --the HUGE_EQUIP_HACK flags tells the tool that the equip is a synchronous
- --call as a result of parenting an animation to the character, which happens
- --when the tool is picked up from the workspace, but not during normal equips
- --(Why does this happen???), if this is the case, the call should be rederrred
- --one tick to ensure that all of the gear's loading can complete before it's
- --equipped event is called.
- --TODO: Blame John for this.
- Delay(0, function()
- this.Equipped:fire(mouse)
- end)
- else
- --otherwise, proceed as normal
- this.Equipped:fire(mouse)
- end
- end)
- script.Parent.Unequipped:connect(function()
- --before my teardown, fire the event
- this.Unequipped:fire()
- --delete all my garbage
- this.Bin:cleanAll()
- end)
- end)
- local ChargeTime = 1 --1 second
- Tool.AnimationProvider:registerAnimation('charge', 'http://www.roblox.com/asset/?id=69803963')
- Tool.AnimationProvider:registerAnimation('check', 'http://www.roblox.com/asset/?id=69803972')
- Tool.AnimationProvider:registerAnimation('equip', 'http://www.roblox.com/asset/?id=69803982')
- Tool.AnimationProvider:registerAnimation('stab', 'http://www.roblox.com/asset/?id=69803991')
- class'WeaponDamage'(nil, function(def)
- local mDamage = 0
- function def:setDamage(n)
- mDamage = n
- end
- function def:getDamage()
- return mDamage
- end
- end)
- function FindHumanoid(part)
- if not part.Parent then return end
- if part.Parent:FindFirstChild("Humanoid") then
- return part.Parent.Humanoid
- elseif part.Parent.Parent and part.Parent.Parent:FindFirstChild("Humanoid") then
- return part.Parent.Parent.Humanoid
- end
- end
- local mGui = Create'ScreenGui'{
- Name = "SpearGui",
- Create'Frame'{
- Name = "ChargeFrame",
- Style = 'RobloxRound',
- Size = UDim2.new(0, 256, 0, 32),
- Position = UDim2.new(0.5, -128, 1, -128),
- Create'Frame'{
- Name = "ProgressBar",
- Size = UDim2.new(0, 0, 1, 0),
- BackgroundColor3 = Color3.new(0.8, 0.2, 0.2),
- },
- Create'TextLabel'{
- Name = "ProgressLabel",
- Size = UDim2.new(1, 0, 1, 0),
- BackgroundTransparency = 1,
- Font = 'Arial',
- FontSize = 'Size18',
- TextColor3 = Color3.new(0.8, 0.8, 0.8),
- Text = "Click and hold to charge attack!",
- },
- },
- }
- function setProgress(frac)
- frac = frac or 0
- if frac == 0 then
- mGui.ChargeFrame.ProgressLabel.Text = "Click and hold to charge attack!"
- else
- mGui.ChargeFrame.ProgressLabel.Text = "Charging "..(math.floor(frac*100)).."%"
- end
- mGui.ChargeFrame.ProgressBar.Size = UDim2.new(frac, 0, 1, 0)
- end
- local mDamageCn;
- local mCheckHitCn;
- local CurrentCharge = 0
- local Equipped = false
- local ClickNum = 0
- local Checking = false
- local CheckVelocity = 0
- Tool.MouseClick:connect(function()
- ClickNum = ClickNum + 1
- local thisClick = ClickNum
- --
- WeaponDamage:setDamage(25)
- Tool.AnimationProvider:getAnimation('stab'):Play(0, 1, 4)
- Delay(0.3, function()
- if Equipped and Tool.MouseDown and ClickNum == thisClick then
- WeaponDamage:setDamage(0)
- --Imma charjin mah speeaar!!
- Tool.AnimationProvider:getAnimation('charge'):Play(0, 1, 8)
- Tool.Humanoid.WalkSpeed = 0
- --
- CurrentCharge = 0
- local startCharge = tick()
- while Tool.MouseDown do
- CurrentCharge = math.min(1, (tick()-startCharge)/ChargeTime)
- setProgress(CurrentCharge)
- wait()
- end
- setProgress()
- --
- Checking = true
- Tool.Humanoid.WalkSpeed = 16
- Tool.AnimationProvider:getAnimation('charge'):Stop(0)
- Tool.AnimationProvider:getAnimation('check'):Play(0, 1, 8)
- Tool.Humanoid.Jump = true
- --
- local torso = Tool.Character.Torso
- local fly = Create'BodyVelocity'{
- velocity = torso.CFrame.lookVector*CurrentCharge*100,
- maxForce = Vector3.new(1000000, 0, 1000000),
- Parent = torso,
- }
- local forceDown = Create'BodyForce'{
- force = Vector3.new(0, -15000, 0),
- Parent = torso,
- }
- --
- local footHitGroundCn;
- local continueWait = true
- if Tool.Character:FindFirstChild("Right Leg") then
- footHitGroundCn = Tool.Character["Right Leg"].Touched:connect(function(part)
- continueWait = false
- end)
- end
- local startJumpTime = tick()
- while (tick()-startJumpTime) < 1 and continueWait do wait() end
- Tool.AnimationProvider:getAnimation('check'):Stop()
- if footHitGroundCn then
- footHitGroundCn:disconnect()
- end
- fly:Destroy()
- forceDown:Destroy()
- Delay(0.5, function()
- Checking = false
- end)
- else
- wait(0.4)
- if ClickNum == thisClick then
- WeaponDamage:setDamage(0)
- end
- end
- end)
- end)
- Tool.Equipped:connect(function()
- Tool.Handle = Tool.Tool.Handle
- mGui.Parent = Tool.Player.PlayerGui
- Tool.AnimationProvider:getAnimation('equip'):Play(0.1, 1, 3)
- --
- Equipped = true
- Delay(0, function()
- --make a "tip" for the spear since only it's top should do damage
- local tipPart = Create'Part'{
- Name = "HandleTip",
- Parent = Tool.Tool,
- FormFactor = 'Custom',
- CanCollide = false,
- Transparency = 1,
- Size = Vector3.new(0.7, 1.5, 0.7),
- }
- local tipWeld = Create'Weld'{
- Name = "HandleTipWeld",
- Parent = Tool.Handle,
- Part0 = Tool.Handle,
- C0 = CFrame.new(0, 2.8, 0),
- }
- tipWeld.Part1 = tipPart
- --add handling for damage
- mDamageCn = tipPart.Touched:connect(function(part)
- local hum = FindHumanoid(part)
- if hum then
- TagHumanoid(hum)
- hum:TakeDamage(WeaponDamage:getDamage())
- end
- end)
- mCheckHitCn = Tool.Handle.Touched:connect(function(part)
- if Checking then
- local hum = FindHumanoid(part)
- if hum then
- local torso = hum.Parent:FindFirstChild("Torso")
- if torso then
- hum.Jump = true
- local myTorso = Tool.Character.Torso
- local fly = Create'BodyVelocity'{
- velocity = myTorso.CFrame.lookVector*CurrentCharge*120,
- maxForce = Vector3.new(1000000, 0, 1000000),
- Parent = torso,
- }
- Tool.Bin:add(function()
- fly:Destroy()
- end, 'kill-hit-fly')
- Delay(0.5, function()
- fly:Destroy()
- end)
- end
- TagHumanoid(hum)
- hum:TakeDamage(50*CurrentCharge)
- end
- end
- end)
- end)
- end)
- Tool.Unequipped:connect(function()
- mGui.Parent = nil
- Tool.AnimationProvider:getAnimation('equip'):Stop(0)
- Tool.AnimationProvider:getAnimation('stab'):Stop(0)
- Tool.AnimationProvider:getAnimation('charge'):Stop(0)
- Tool.AnimationProvider:getAnimation('check'):Stop(0)
- --
- Equipped = false
- if mDamageCn then
- mDamageCn:disconnect()
- mCheckHitCn:disconnect()
- mDamageCn = nil
- mCheckHitCn = nil
- end
- end)
- end))
- Script10.Name = "MotorizeRightGrip"
- Script10.Parent = LocalScript9
- table.insert(cors,sandbox(Script10,function()
- print("Run RightgripScript, parent=", script.Parent)
- function Create(ty)
- return function(data)
- local obj = Instance.new(ty)
- for k, v in pairs(data) do
- if type(k) == 'number' then
- v.Parent = obj
- else
- obj[k] = v
- end
- end
- return obj
- end
- end
- local Tool = script.Parent.Parent
- local armChildRemovedConn = nil
- local Motor6DGrip = nil
- local EquippedNum = 0
- Tool.Equipped:connect(function()
- EquippedNum = EquippedNum + 1
- local myEquip = EquippedNum
- --some vars
- local Player = game.Players:GetPlayerFromCharacter(Tool.Parent)
- local Character = Player.Character
- local rightarm = Character:FindFirstChild('Right Arm')
- if rightarm and rightarm:FindFirstChild('RightGrip') then
- local rightGrip = rightarm['RightGrip']
- local handle = rightGrip.Part1
- --kill my joint when the normal joint is removed
- --this must be done here so that the joint is removed
- --_right away_ after unequipping and the character doesn't
- --glitch up.
- local armChildRemovedConn = rightarm.ChildRemoved:connect(function(ch)
- if ch == rightGrip then
- if Motor6DGrip then
- Motor6DGrip:Remove()
- Motor6DGrip = nil
- end
- --
- if handle and Character:FindFirstChild('Torso') then
- if Tool.Parent.Parent:IsA('Player') then
- --the sword has been deselected
- --put the sword far away so the user doesn't notice that the handle doesn't
- --update for about 0.1 seconds after selecting the tool.
- handle.CFrame = CFrame.new(100000, 100000, 100000)
- else
- --if in the workspace, position the handle where it should be dropped
- --use the size of the handle to make sure it's dropped far enough away
- handle.CFrame = Character.Torso.CFrame * CFrame.new(0, 0, -(handle.Size.magnitude+2))
- end
- end
- end
- end)
- --make my new joint
- Motor6DGrip = Create'Motor6D'{
- Name = 'RightGrip_Motor',
- Part0 = rightarm,
- Part1 = handle,
- }
- --kill the old weld
- rightGrip.Part1 = nil
- rightGrip.Part0 = nil
- Motor6DGrip.Parent = rightGrip.Parent
- end
- end)
- Tool.Unequipped:connect(function()
- EquippedNum = EquippedNum + 1
- if armChildRemovedConn then
- armChildRemovedConn:disconnect()
- armChildRemovedConn = nil
- end
- end)
- end))
- LocalScript11.Name = "MouseIcon"
- LocalScript11.Parent = Tool0
- table.insert(cors,sandbox(LocalScript11,function()
- --Made by Luckymaxer
- Mouse_Icon = "rbxasset://textures/GunCursor.png"
- Reloading_Icon = "rbxasset://textures/GunWaitCursor.png"
- Tool = script.Parent
- Mouse = nil
- function UpdateIcon()
- if Mouse then
- Mouse.Icon = Tool.Enabled and Mouse_Icon or Reloading_Icon
- end
- end
- function OnEquipped(ToolMouse)
- Mouse = ToolMouse
- UpdateIcon()
- end
- function OnChanged(Property)
- if Property == "Enabled" then
- UpdateIcon()
- end
- end
- Tool.Equipped:Connect(OnEquipped)
- Tool.Changed:Connect(OnChanged)
- end))
- Script12.Name = "SwordScript"
- Script12.Parent = Tool0
- table.insert(cors,sandbox(Script12,function()
- --Rescripted by Luckymaxer
- --EUROCOW WAS HERE BECAUSE I MADE THE PARTICLES AND THEREFORE THIS ENTIRE SWORD PRETTY AND LOOK PRETTY WORDS AND I'D LIKE TO DEDICATE THIS TO MY FRIENDS AND HI LUCKYMAXER PLS FIX SFOTH SWORDS TY LOVE Y'ALl
- --Updated for R15 avatars by StarWars
- --Re-updated by TakeoHonorable
- Tool = script.Parent
- Handle = Tool:WaitForChild("Handle")
- function Create(ty)
- return function(data)
- local obj = Instance.new(ty)
- for k, v in pairs(data) do
- if type(k) == 'number' then
- v.Parent = obj
- else
- obj[k] = v
- end
- end
- return obj
- end
- end
- local BaseUrl = "rbxassetid://"
- Players = game:GetService("Players")
- Debris = game:GetService("Debris")
- RunService = game:GetService("RunService")
- DamageValues = {
- BaseDamage = 5,
- SlashDamage = 10,
- LungeDamage = 30
- }
- --For R15 avatars
- Animations = {
- R15Slash = 522635514,
- R15Lunge = 522638767
- }
- Damage = DamageValues.BaseDamage
- Grips = {
- Up = CFrame.new(0, 0, -1.70000005, 0, 0, 1, 1, 0, 0, 0, 1, 0),
- Out = CFrame.new(0, 0, -1.70000005, 0, 1, 0, 1, -0, 0, 0, 0, -1)
- }
- Sounds = {
- Slash = Handle:WaitForChild("SwordSlash"),
- Lunge = Handle:WaitForChild("SwordLunge"),
- Unsheath = Handle:WaitForChild("Unsheath")
- }
- ToolEquipped = false
- --For Omega Rainbow Katana thumbnail to display a lot of particles.
- for i, v in pairs(Handle:GetChildren()) do
- if v:IsA("ParticleEmitter") then
- v.Rate = 20
- end
- end
- Tool.Grip = Grips.Up
- Tool.Enabled = true
- function IsTeamMate(Player1, Player2)
- return (Player1 and Player2 and not Player1.Neutral and not Player2.Neutral and Player1.TeamColor == Player2.TeamColor)
- end
- function TagHumanoid(humanoid, player)
- local Creator_Tag = Instance.new("ObjectValue")
- Creator_Tag.Name = "creator"
- Creator_Tag.Value = player
- Debris:AddItem(Creator_Tag, 2)
- Creator_Tag.Parent = humanoid
- end
- function UntagHumanoid(humanoid)
- for i, v in pairs(humanoid:GetChildren()) do
- if v:IsA("ObjectValue") and v.Name == "creator" then
- v:Destroy()
- end
- end
- end
- function Blow(Hit)
- if not Hit or not Hit.Parent or not CheckIfAlive() or not ToolEquipped then
- return
- end
- local RightArm = Character:FindFirstChild("Right Arm") or Character:FindFirstChild("RightHand")
- if not RightArm then
- return
- end
- local RightGrip = RightArm:FindFirstChild("RightGrip")
- if not RightGrip or (RightGrip.Part0 ~= Handle and RightGrip.Part1 ~= Handle) then
- return
- end
- local character = Hit.Parent
- if character == Character then
- return
- end
- local humanoid = character:FindFirstChildOfClass("Humanoid")
- if not humanoid or humanoid.Health == 0 then
- return
- end
- local player = Players:GetPlayerFromCharacter(character)
- if player and (player == Player or IsTeamMate(Player, player)) then
- return
- end
- UntagHumanoid(humanoid)
- TagHumanoid(humanoid, Player)
- humanoid:TakeDamage(Damage)
- end
- function Attack()
- Damage = DamageValues.SlashDamage
- Sounds.Slash:Play()
- if Humanoid then
- if Humanoid.RigType == Enum.HumanoidRigType.R6 then
- local Anim = Instance.new("StringValue")
- Anim.Name = "toolanim"
- Anim.Value = "Slash"
- Anim.Parent = Tool
- elseif Humanoid.RigType == Enum.HumanoidRigType.R15 then
- local Anim = Tool:FindFirstChild("R15Slash")
- if Anim then
- local Track = Humanoid:LoadAnimation(Anim)
- Track:Play(0)
- end
- end
- end
- end
- function Lunge()
- Damage = DamageValues.LungeDamage
- Sounds.Lunge:Play()
- if Humanoid then
- if Humanoid.RigType == Enum.HumanoidRigType.R6 then
- local Anim = Instance.new("StringValue")
- Anim.Name = "toolanim"
- Anim.Value = "Lunge"
- Anim.Parent = Tool
- elseif Humanoid.RigType == Enum.HumanoidRigType.R15 then
- local Anim = Tool:FindFirstChild("R15Lunge")
- if Anim then
- local Track = Humanoid:LoadAnimation(Anim)
- Track:Play(0)
- end
- end
- end
- --[[
- if CheckIfAlive() then
- local Force = Instance.new("BodyVelocity")
- Force.velocity = Vector3.new(0, 10, 0)
- Force.maxForce = Vector3.new(0, 4000, 0)
- Debris:AddItem(Force, 0.4)
- Force.Parent = Torso
- end
- ]]
- wait(0.2)
- Tool.Grip = Grips.Out
- wait(0.6)
- Tool.Grip = Grips.Up
- Damage = DamageValues.SlashDamage
- end
- Tool.Enabled = true
- LastAttack = 0
- function Activated()
- if not Tool.Enabled or not ToolEquipped or not CheckIfAlive() then
- return
- end
- Tool.Enabled = false
- local Tick = RunService.Stepped:wait()
- if (Tick - LastAttack < 0.2) then
- Lunge()
- else
- Attack()
- end
- LastAttack = Tick
- --wait(0.5)
- Damage = DamageValues.BaseDamage
- local SlashAnim = (Tool:FindFirstChild("R15Slash") or Create("Animation"){
- Name = "R15Slash",
- AnimationId = BaseUrl .. Animations.R15Slash,
- Parent = Tool
- })
- local LungeAnim = (Tool:FindFirstChild("R15Lunge") or Create("Animation"){
- Name = "R15Lunge",
- AnimationId = BaseUrl .. Animations.R15Lunge,
- Parent = Tool
- })
- Tool.Enabled = true
- end
- function CheckIfAlive()
- return (((Player and Player.Parent and Character and Character.Parent and Humanoid and Humanoid.Parent and Humanoid.Health > 0 and Torso and Torso.Parent) and true) or false)
- end
- function Equipped()
- Character = Tool.Parent
- Player = Players:GetPlayerFromCharacter(Character)
- Humanoid = Character:FindFirstChildOfClass("Humanoid")
- Torso = Character:FindFirstChild("Torso") or Character:FindFirstChild("HumanoidRootPart")
- if not CheckIfAlive() then
- return
- end
- ToolEquipped = true
- Sounds.Unsheath:Play()
- end
- function Unequipped()
- Tool.Grip = Grips.Up
- ToolEquipped = false
- end
- Tool.Activated:Connect(Activated)
- Tool.Equipped:Connect(Equipped)
- Tool.Unequipped:Connect(Unequipped)
- Connection = Handle.Touched:Connect(Blow)
- end))
- for i,v in pairs(mas:GetChildren()) do
- v.Parent = script
- pcall(function() v:MakeJoints() end)
- end
- mas:Destroy()
- for i,v in pairs(cors) do
- spawn(function()
- pcall(v)
- end)
- end
Advertisement
Add Comment
Please, Sign In to add comment