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,game,owner = owner,game
- local RealPlayer = Player
- do
- print("FE Compatibility code by Mokiros")
- local rp = RealPlayer
- script.Parent = rp.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,Functions={},Connect=function(self,f)table.insert(self.Functions,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 then
- for _,f in pairs(t.Functions) do
- f(...)
- end
- end
- end
- m.TrigEvent = te
- UIS.TrigEvent = te
- Event.OnServerEvent:Connect(function(plr,io)
- if plr~=rp then return end
- m.Target = io.Target
- m.Hit = io.Hit
- if not io.isMouse then
- 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 Mouse = Player:GetMouse()
- 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,Hit=Mouse.Hit,Target=Mouse.Target})
- end
- UIS.InputBegan:Connect(input)
- UIS.InputEnded:Connect(input)
- 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)
- ----Sandboxed game object that allows the usage of client-side methods and services
- --Real game object
- local _rg = game
- --Metatable for fake service
- local fsmt = {
- __index = function(self,k)
- local s = rawget(self,"_RealService")
- if s then return s[k] end
- end,
- __newindex = function(self,k,v)
- local s = rawget(self,"_RealService")
- if s then s[k]=v end
- end,
- __call = function(self,...)
- local s = rawget(self,"_RealService")
- if s then return s(...) end
- end
- }
- local function FakeService(t,RealService)
- t._RealService = typeof(RealService)=="string" and _rg:GetService(RealService) or RealService
- return setmetatable(t,fsmt)
- end
- --Fake game object
- local g = {
- GetService = function(self,s)
- return self[s]
- end,
- Players = FakeService({
- LocalPlayer = FakeService({GetMouse=function(self)return m end},Player)
- },"Players"),
- UserInputService = FakeService(UIS,"UserInputService"),
- ContextActionService = FakeService(CAS,"ContextActionService"),
- }
- rawset(g.Players,"localPlayer",g.Players.LocalPlayer)
- g.service = g.GetService
- g.RunService = FakeService({
- RenderStepped = _rg:GetService("RunService").Heartbeat,
- BindToRenderStep = function(self,name,_,fun)
- end,
- UnbindFromRenderStep = function(self,name)
- self._btrs[name]:Disconnect()
- end,
- },"RunService")
- setmetatable(g,{
- __index=function(self,s)
- return _rg:GetService(s) or typeof(_rg[s])=="function"
- and function(_,...)return _rg[s](_rg,...)end or _rg[s]
- end,
- __newindex = fsmt.__newindex,
- __call = fsmt.__call
- })
- --Changing owner to fake player object to support owner:GetMouse()
- game,owner = g,g.Players.LocalPlayer
- end
- local la = Instance.new("Weld")
- la.Parent = script.Parent["Left Arm"]
- la.Part0 = script.Parent.HumanoidRootPart
- la.Part1 = script.Parent["Left Arm"]
- la.C1 = CFrame.new(1,.3,.35) * CFrame.fromEulerAnglesXYZ(-1.5,.9,0)
- local ra = Instance.new("Weld")
- ra.Parent = script.Parent["Right Arm"]
- ra.Part0 = script.Parent.HumanoidRootPart
- ra.Part1 = script.Parent["Right Arm"]
- ra.C1 = CFrame.new(-1,.4,.7) * CFrame.fromEulerAnglesXYZ(-1.5,-.2,.15)
- local attack = false
- local mouse = game.Players[script.Parent.Name]:GetMouse()
- local d = false
- function damage(hit)
- local h = hit.Parent:findFirstChildOfClass("Humanoid")
- if h ~= nil and attack == true then
- h.Health = h.Health - math.random(10,20)
- end
- end
- local katana = Instance.new("Model")
- katana.Parent = script.Parent
- katana.Name = "Katana"
- local handle = Instance.new("Part")
- handle.Parent = katana
- handle.BrickColor = BrickColor.new('Really black')
- handle.Name = "Handle"
- handle.Size = Vector3.new(.5,2,.5)
- handle.FrontSurface = Enum.SurfaceType.SmoothNoOutlines
- handle.BackSurface = Enum.SurfaceType.SmoothNoOutlines
- handle.LeftSurface = Enum.SurfaceType.SmoothNoOutlines
- handle.RightSurface = Enum.SurfaceType.SmoothNoOutlines
- handle.BottomSurface = Enum.SurfaceType.SmoothNoOutlines
- handle.TopSurface = Enum.SurfaceType.SmoothNoOutlines
- handle.CanCollide = false
- local hw = Instance.new("Weld")
- hw.Parent = handle
- hw.Part0 = handle
- hw.Part1 = script.Parent["Right Arm"]
- hw.C1 = CFrame.new(0,-1,.4) * CFrame.fromEulerAnglesXYZ(1.6,0,0)
- local part = Instance.new("Part")
- part.Parent = katana
- part.BrickColor = BrickColor.new('Dark stone grey')
- part.Name = "KatanaPart"
- part.Size = Vector3.new(.5,.2,1)
- part.FrontSurface = Enum.SurfaceType.SmoothNoOutlines
- part.BackSurface = Enum.SurfaceType.SmoothNoOutlines
- part.LeftSurface = Enum.SurfaceType.SmoothNoOutlines
- part.RightSurface = Enum.SurfaceType.SmoothNoOutlines
- part.BottomSurface = Enum.SurfaceType.SmoothNoOutlines
- part.TopSurface = Enum.SurfaceType.SmoothNoOutlines
- part.CanCollide = false
- local pw = Instance.new("Weld")
- pw.Parent = part
- pw.Part0 = part
- pw.Part1 = handle
- pw.C1 = CFrame.new(0,-1,0) * CFrame.fromEulerAnglesXYZ(0,0,0)
- local part = Instance.new("Part")
- part.Parent = katana
- part.BrickColor = BrickColor.new('Dark stone grey')
- part.Name = "KatanaPart"
- part.Size = Vector3.new(.2,.2,.7)
- part.FrontSurface = Enum.SurfaceType.SmoothNoOutlines
- part.BackSurface = Enum.SurfaceType.SmoothNoOutlines
- part.LeftSurface = Enum.SurfaceType.SmoothNoOutlines
- part.RightSurface = Enum.SurfaceType.SmoothNoOutlines
- part.BottomSurface = Enum.SurfaceType.SmoothNoOutlines
- part.TopSurface = Enum.SurfaceType.SmoothNoOutlines
- part.CanCollide = false
- local pw = Instance.new("Weld")
- pw.Parent = part
- pw.Part0 = part
- pw.Part1 = handle
- pw.C1 = CFrame.new(.35,-1,0) * CFrame.fromEulerAnglesXYZ(0,0,0)
- local part = Instance.new("Part")
- part.Parent = katana
- part.BrickColor = BrickColor.new('Dark stone grey')
- part.Name = "KatanaPart"
- part.Size = Vector3.new(.2,.2,.7)
- part.FrontSurface = Enum.SurfaceType.SmoothNoOutlines
- part.BackSurface = Enum.SurfaceType.SmoothNoOutlines
- part.LeftSurface = Enum.SurfaceType.SmoothNoOutlines
- part.RightSurface = Enum.SurfaceType.SmoothNoOutlines
- part.BottomSurface = Enum.SurfaceType.SmoothNoOutlines
- part.TopSurface = Enum.SurfaceType.SmoothNoOutlines
- part.CanCollide = false
- local pw = Instance.new("Weld")
- pw.Parent = part
- pw.Part0 = part
- pw.Part1 = handle
- pw.C1 = CFrame.new(-.35,-1,0) * CFrame.fromEulerAnglesXYZ(0,0,0)
- local blade = Instance.new("Part")
- blade.Parent = katana
- blade.BrickColor = BrickColor.new('White')
- blade.Name = "DamagingBlade"
- blade.Size = Vector3.new(.1,3,.4)
- blade.FrontSurface = Enum.SurfaceType.SmoothNoOutlines
- blade.BackSurface = Enum.SurfaceType.SmoothNoOutlines
- blade.LeftSurface = Enum.SurfaceType.SmoothNoOutlines
- blade.RightSurface = Enum.SurfaceType.SmoothNoOutlines
- blade.BottomSurface = Enum.SurfaceType.SmoothNoOutlines
- blade.TopSurface = Enum.SurfaceType.SmoothNoOutlines
- blade.CanCollide = false
- local bw = Instance.new("Weld")
- bw.Parent = blade
- bw.Part0 = blade
- bw.Part1 = handle
- bw.C1 = CFrame.new(0,-2.5,0) * CFrame.fromEulerAnglesXYZ(0,0,0)
- local blade2 = Instance.new("Part")
- blade2.Parent = katana
- blade2.BrickColor = BrickColor.new('White')
- blade2.Name = "Blade"
- blade2.Size = Vector3.new(.1,.4,.2)
- blade2.FrontSurface = Enum.SurfaceType.SmoothNoOutlines
- blade2.BackSurface = Enum.SurfaceType.SmoothNoOutlines
- blade2.LeftSurface = Enum.SurfaceType.SmoothNoOutlines
- blade2.RightSurface = Enum.SurfaceType.SmoothNoOutlines
- blade2.BottomSurface = Enum.SurfaceType.SmoothNoOutlines
- blade2.TopSurface = Enum.SurfaceType.SmoothNoOutlines
- blade2.CanCollide = false
- local bw2 = Instance.new("Weld")
- bw2.Parent = blade2
- bw2.Part0 = blade2
- bw2.Part1 = handle
- bw2.C1 = CFrame.new(0,-4.2,0) * CFrame.fromEulerAnglesXYZ(0,0,0)
- local a0 = Instance.new("Attachment")
- a0.Parent = blade
- a0.Position = Vector3.new(0,1.5,0)
- local a1 = Instance.new("Attachment")
- a1.Parent = blade
- a1.Position = Vector3.new(0,-2,0)
- local trail = Instance.new("Trail")
- trail.Parent = blade
- trail.Transparency = NumberSequence.new(.5,1)
- trail.Attachment0 = a0
- trail.Attachment1 = a1
- trail.Lifetime = .1
- function attack()
- if d == false then
- local attackID = 0
- attackID = math.random(1,2)
- attack = true
- d = true
- if attackID == 1 then
- la.C1 = CFrame.new(1,.3,.35) * CFrame.fromEulerAnglesXYZ(-1.5,.9,0)
- ra.C1 = CFrame.new(-1,.4,.7) * CFrame.fromEulerAnglesXYZ(-1.5,-.2,.15)
- wait(.01)
- la.C1 = CFrame.new(1,.3,.35) * CFrame.fromEulerAnglesXYZ(-1.5,.9,0)
- ra.C1 = CFrame.new(-1,.4,.7) * CFrame.fromEulerAnglesXYZ(-1.5,-.2,.4)
- wait(.05)
- la.C1 = CFrame.new(1,-.1,.35) * CFrame.fromEulerAnglesXYZ(-1,.9,0)
- ra.C1 = CFrame.new(-1,0,.7) * CFrame.fromEulerAnglesXYZ(-1,-.2,.4)
- wait(.05)
- la.C1 = CFrame.new(1,.1,.2) * CFrame.fromEulerAnglesXYZ(-.5,.9,0)
- ra.C1 = CFrame.new(-1,.2,.5) * CFrame.fromEulerAnglesXYZ(-.5,-.2,.4)
- wait(.05)
- la.C1 = CFrame.new(1,.1,.1) * CFrame.fromEulerAnglesXYZ(0,.9,0)
- ra.C1 = CFrame.new(-1,.2,.3) * CFrame.fromEulerAnglesXYZ(0,-.2,.4)
- wait(.05)
- la.C1 = CFrame.new(1,.1,.2) * CFrame.fromEulerAnglesXYZ(-.5,.9,0)
- ra.C1 = CFrame.new(-1,.2,.5) * CFrame.fromEulerAnglesXYZ(-.5,-.2,.4)
- wait(.05)
- la.C1 = CFrame.new(1,-.1,.35) * CFrame.fromEulerAnglesXYZ(-1,.9,0)
- ra.C1 = CFrame.new(-1,0,.7) * CFrame.fromEulerAnglesXYZ(-1,-.2,.4)
- wait(.01)
- la.C1 = CFrame.new(1,.3,.35) * CFrame.fromEulerAnglesXYZ(-1.5,.9,0)
- ra.C1 = CFrame.new(-1,.4,.7) * CFrame.fromEulerAnglesXYZ(-1.5,-.2,.4)
- wait(.01)
- la.C1 = CFrame.new(1,.3,.35) * CFrame.fromEulerAnglesXYZ(-1.5,.9,0)
- ra.C1 = CFrame.new(-1,.4,.7) * CFrame.fromEulerAnglesXYZ(-1.5,-.2,.15)
- end
- if attackID == 2 then
- la.C1 = CFrame.new(1,.3,.35) * CFrame.fromEulerAnglesXYZ(-1.5,.9,0)
- ra.C1 = CFrame.new(-1,.4,.7) * CFrame.fromEulerAnglesXYZ(-1.5,-.2,.15)
- wait(.01)
- la.C1 = CFrame.new(1,.3,.35) * CFrame.fromEulerAnglesXYZ(-1.5,.9,.3)
- ra.C1 = CFrame.new(-1,.4,.7) * CFrame.fromEulerAnglesXYZ(-1.5,-.2,.5)
- wait(.01)
- la.C1 = CFrame.new(1,.3,.35) * CFrame.fromEulerAnglesXYZ(-1.5,.9,.6)
- ra.C1 = CFrame.new(-1,.4,.7) * CFrame.fromEulerAnglesXYZ(-1.5,-.2,.8)
- wait(.05)
- la.C1 = CFrame.new(1,.3,.35) * CFrame.fromEulerAnglesXYZ(-1,.9,.6)
- ra.C1 = CFrame.new(-1,.4,.7) * CFrame.fromEulerAnglesXYZ(-1,-.2,.8)
- wait(.05)
- la.C1 = CFrame.new(1,.3,.35) * CFrame.fromEulerAnglesXYZ(-.5,.9,.6)
- ra.C1 = CFrame.new(-1,.4,.7) * CFrame.fromEulerAnglesXYZ(-.5,-.2,.8)
- wait(.05)
- la.C1 = CFrame.new(1,.3,.35) * CFrame.fromEulerAnglesXYZ(-1,.9,.6)
- ra.C1 = CFrame.new(-1,.4,.7) * CFrame.fromEulerAnglesXYZ(-1,-.2,.8)
- wait(.1)
- la.C1 = CFrame.new(1,.3,.35) * CFrame.fromEulerAnglesXYZ(-1.5,.9,0)
- ra.C1 = CFrame.new(-1,.4,.7) * CFrame.fromEulerAnglesXYZ(-1.5,-.2,.15)
- end
- attack = false
- d = false
- end
- end
- mouse.Button1Down:connect(attack)
- blade.Touched:connect(damage)
Add Comment
Please, Sign In to add comment