Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
- local Player,Mouse,mouse,UserInputService,ContextActionService = owner
- do
- print("FE Compatibility code by Mokiros")
- script.Parent = Player.Character
- --RemoteEvent for communicating
- local Event = Instance.new("RemoteEvent")
- Event.Name = "UserInput_Event"
- --Fake event to make stuff like Mouse.KeyDown work
- local function fakeEvent()
- local t = {_fakeEvent=true,Connect=function(self,f)self.Function=f end}
- t.connect = t.Connect
- return t
- end
- --Creating fake input objects with fake variables
- local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent()}
- local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
- local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
- CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
- end}
- --Merged 2 functions into one by checking amount of arguments
- CAS.UnbindAction = CAS.BindAction
- --This function will trigger the events that have been :Connect()'ed
- local function te(self,ev,...)
- local t = m[ev]
- if t and t._fakeEvent and t.Function then
- t.Function(...)
- end
- end
- m.TrigEvent = te
- UIS.TrigEvent = te
- Event.OnServerEvent:Connect(function(plr,io)
- if plr~=Player then return end
- if io.isMouse then
- m.Target = io.Target
- m.Hit = io.Hit
- else
- local b = io.UserInputState == Enum.UserInputState.Begin
- if io.UserInputType == Enum.UserInputType.MouseButton1 then
- return m:TrigEvent(b and "Button1Down" or "Button1Up")
- end
- for _,t in pairs(CAS.Actions) do
- for _,k in pairs(t.Keys) do
- if k==io.KeyCode then
- t.Function(t.Name,io.UserInputState,io)
- end
- end
- end
- m:TrigEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
- UIS:TrigEvent(b and "InputBegan" or "InputEnded",io,false)
- end
- end)
- Event.Parent = NLS([==[
- local Player = game:GetService("Players").LocalPlayer
- local Event = script:WaitForChild("UserInput_Event")
- local UIS = game:GetService("UserInputService")
- local input = function(io,a)
- if a then return end
- --Since InputObject is a client-side instance, we create and pass table instead
- Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState})
- end
- UIS.InputBegan:Connect(input)
- UIS.InputEnded:Connect(input)
- local Mouse = Player:GetMouse()
- local h,t
- --Give the server mouse data 30 times every second, but only if the values changed
- --If player is not moving their mouse, client won't fire events
- while wait(1/30) do
- if h~=Mouse.Hit or t~=Mouse.Target then
- h,t=Mouse.Hit,Mouse.Target
- Event:FireServer({isMouse=true,Target=t,Hit=h})
- end
- end]==],Player.Character)
- Mouse,mouse,UserInputService,ContextActionService = m,m,UIS,CAS
- end
- spawn (function()
- -- Objects
- local Sword = Instance.new("Model")
- local Player = owner
- local Char = Player.Character
- local BaseAttachment = Instance.new("Attachment")
- local BladeAttackment = Instance.new("Attachment")
- local Blade = Instance.new("Part")
- local Trail = Instance.new("Trail")
- local RunService = game:GetService("RunService")
- local Handle = Instance.new("Part")
- local HandleToBlade = Instance.new("Weld")
- local HandToTorso = Instance.new("Weld")
- local HandleToHand = Instance.new("Weld")
- local BladeToSharp = Instance.new("Weld")
- local Sharp = Instance.new("WedgePart")
- local Slash = false
- local Blood = Instance.new("Part")
- local BloodCont = Instance.new("Model")
- local Smoothner = Instance.new("BlockMesh")
- local Attacking = false
- local HitSound = Instance.new("Sound")
- local SlashSound = Instance.new("Sound")
- local CFrames =
- {
- t_HandToTorso =
- {
- BackClick = CFrame.new(-1.5, 1, 0) * CFrame.Angles(3.5, 0, 0),
- BackStab = CFrame.new(-1.5, 0.5, -0.5) * CFrame.Angles(1.5, 0, 0),
- FrontClick = CFrame.new(-1.5, 0, 0) * CFrame.Angles(0, 0, 0),
- FrontStab = CFrame.new(-1.5, 0.5, 0.5) * CFrame.Angles(-1.5, 0, 0)
- },
- t_HandleToHand =
- {
- BackClick = CFrame.new(0, 0, 0) * CFrame.Angles(-5, 0.2, 1),
- BackStab = CFrame.new(0, 0, 0) * CFrame.Angles(0.3, 0, 0),
- FrontClick = CFrame.new(0, 0, 0) * CFrame.Angles(1.5, 0, 0),
- FrontStab = CFrame.new(0, 0, 0) * CFrame.Angles(3, 0, 0)
- }
- }
- -- Assets
- game.ContentProvider:Preload("rbxassetid://196969716") -- Trail Texutre
- game.ContentProvider:Preload("rbxassetid://158037267") -- Slash Sound
- game.ContentProvider:Preload("rbxassetid://186311262") -- Hit Sound
- -- Properties
- Sword.Parent = Char
- Sword.Name = "Sword"
- Handle.BrickColor = BrickColor.new("Dark orange")
- Handle.Material = "Marble"
- Handle.Name = "Handle"
- Handle.Anchored = false
- Handle.CanCollide = false
- Handle.Size = Vector3.new(0.1, 1, 0.35)
- Handle.BackSurface = "SmoothNoOutlines"
- Handle.BottomSurface = "SmoothNoOutlines"
- Handle.FrontSurface = "SmoothNoOutlines"
- Handle.LeftSurface = "SmoothNoOutlines"
- Handle.RightSurface = "SmoothNoOutlines"
- Handle.TopSurface = "SmoothNoOutlines"
- Blade.BrickColor = BrickColor.new("Fossil")
- Blade.Material = "Neon"
- Blade.Name = "Blade"
- Blade.Anchored = false
- Blade.CanCollide = false
- Blade.Size = Vector3.new(0.1, 4.84, 0.35)
- Blade.BackSurface = "SmoothNoOutlines"
- Blade.BottomSurface = "SmoothNoOutlines"
- Blade.FrontSurface = "SmoothNoOutlines"
- Blade.LeftSurface = "SmoothNoOutlines"
- Blade.RightSurface = "SmoothNoOutlines"
- Blade.TopSurface = "SmoothNoOutlines"
- Sharp.BrickColor = BrickColor.new("Fossil")
- Sharp.Material = "Neon"
- Sharp.Name = "Sharp"
- Sharp.Anchored = false
- Sharp.CanCollide = false
- Sharp.Size = Vector3.new(0.1, 1, 0.35)
- Sharp.BackSurface = "SmoothNoOutlines"
- Sharp.BottomSurface = "SmoothNoOutlines"
- Sharp.FrontSurface = "SmoothNoOutlines"
- Sharp.LeftSurface = "SmoothNoOutlines"
- Sharp.RightSurface = "SmoothNoOutlines"
- Sharp.TopSurface = "SmoothNoOutlines"
- Blood.BrickColor = BrickColor.new("Really red")
- Blood.Size = Vector3.new(0.5, 0.3, 0.6)
- BloodCont.Name = "BloodCont"
- Smoothner.Parent = Blood
- BaseAttachment.Parent = Sharp
- BladeAttackment.Parent = Blade
- Trail.Attachment0 = BaseAttachment
- Trail.Attachment1 = BladeAttackment
- Trail.Parent = Sharp
- Trail.Enabled = false
- Trail.Transparency = NumberSequence.new(0, 1)
- Trail.Texture = "rbxassetid://196969716"
- Trail.Lifetime = 0.15
- SlashSound.Parent = Handle
- SlashSound.Name = "SlashSound"
- SlashSound.Volume = 0.4
- SlashSound.SoundId = "rbxassetid://158037267"
- HitSound.Parent = Handle
- HitSound.Name = "HitSound"
- HitSound.Volume = 0.4
- HitSound.PlaybackSpeed = 2.4
- HitSound.SoundId = "rbxassetid://186311262"
- -- Welds
- HandleToBlade.Part0 = Handle
- HandleToBlade.C0 = CFrame.new(0, 2.92, 0)
- HandleToBlade.Part1 = Blade
- HandleToBlade.Name = "HandleToBlade"
- HandleToBlade.Parent = Handle
- BladeToSharp.Part0 = Sharp
- BladeToSharp.C0 = CFrame.new(0, -2.92, 0)
- BladeToSharp.Part1 = Blade
- BladeToSharp.Parent = Handle
- BladeToSharp.Name = "BladeToSharp"
- HandleToHand.Part0 = Handle
- HandleToHand.Name = "HandleToHand"
- HandleToHand.C0 = CFrame.Angles(1.5, 0, 0)
- HandleToHand.C1 = CFrame.new(0, -1, 0)
- HandleToHand.Part1 = Char["Right Arm"]
- HandleToHand.Parent = Handle
- HandToTorso.Part0 = Char["Right Arm"]
- HandToTorso.Part1 = Char.Torso
- HandToTorso.Name = "HandToTorso"
- HandToTorso.Parent = Handle
- HandToTorso.C0 = CFrame.new(-1.5, 0, 0)
- Handle.Parent = Sword
- Blade.Parent = Sword
- Sharp.Parent = Sword
- -- Functions
- Mouse.Button1Down:Connect(function()
- if Slash == false then
- CFrames.t_HandleToHand.Back = CFrame.new(0, 0, 0) * CFrame.Angles(-5, math.random(-1, 1.2), 1)
- Trail.Enabled = true
- Slash = true
- for Back = 0, 1, 0.05 do
- HandleToHand.C0 = HandleToHand.C0:lerp(CFrames.t_HandleToHand.BackClick, Back)
- HandToTorso.C0 = HandToTorso.C0:lerp(CFrames.t_HandToTorso.BackClick, Back)
- RunService.Stepped:wait()
- end
- SlashSound:Play()
- for Front = 0, 1, 0.1 do
- HandleToHand.C0 = HandleToHand.C0:lerp(CFrames.t_HandleToHand.FrontClick, Front)
- HandToTorso.C0 = HandToTorso.C0:lerp(CFrames.t_HandToTorso.FrontClick, Front)
- RunService.Stepped:wait()
- end
- Slash = false
- Trail.Enabled = false
- end
- end)
- Mouse.KeyDown:Connect(function(key)
- if key == "q" and Slash == false then
- Slash = true
- Trail.Enabled = true
- for Back = 0, 1, 0.025 do
- HandleToHand.C0 = HandleToHand.C0:lerp(CFrames.t_HandleToHand.BackStab, Back)
- HandToTorso.C0 = HandToTorso.C0:lerp(CFrames.t_HandToTorso.BackStab, Back)
- RunService.Stepped:wait()
- end
- SlashSound:Play()
- for Front = 0, 1, 0.1 do
- HandleToHand.C0 = HandleToHand.C0:lerp(CFrames.t_HandleToHand.FrontStab, Front)
- HandToTorso.C0 = HandToTorso.C0:lerp(CFrames.t_HandToTorso.FrontStab, Front)
- RunService.Stepped:wait()
- end
- for Def = 0, 1, 0.1 do
- HandleToHand.C0 = HandleToHand.C0:lerp(CFrames.t_HandleToHand.FrontClick, Def)
- HandToTorso.C0 = HandToTorso.C0:lerp(CFrames.t_HandToTorso.FrontClick, Def)
- RunService.Stepped:wait()
- end
- Slash = false
- Trail.Enabled = false
- end
- end)
- Blade.Touched:Connect(function(hit)
- if Slash == true and hit.Parent:FindFirstChild("Humanoid") and hit.Parent ~= game.Players.LocalPlayer.Character and Attacking == false then
- hit.Parent.Humanoid:TakeDamage(math.random(10, 20))
- Handle.HitSound.Playing = true
- Attacking = true
- BloodCont.Parent = hit.Parent.Torso
- for i = 1, math.random(4, 7) do
- local CBlood = Blood:Clone()
- CBlood.Parent = BloodCont
- CBlood.CFrame = hit.Parent.Torso.CFrame
- end
- wait(0.5)
- BloodCont:Remove()
- Attacking = false
- end
- end)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement