Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --just put this on the top of a script and boom 89% works
- --note this does not work on big scripts
- 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
- 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)
- self._btrs[name] = self.Heartbeat:Connect(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 plr = game:service'Players'.LocalPlayer
- local chr = plr.Character
- local hum = chr.Humanoid
- local rarm = chr["Right Arm"]
- local larm= chr["Left Arm"]
- local rleg= chr["Right Leg"]
- local lleg = chr["Left Leg"]
- local root = chr.HumanoidRootPart
- local tors = chr.Torso
- local head = chr.Head
- local RunS = game:GetService("RunService")
- local mouse = plr:GetMouse()
- local RenderS = RunS.RenderStepped
- local t = tick()
- local defAnim = true
- local action = ''
- local CF = {N=CFrame.new,A=CFrame.Angles,fEA=CFrame.fromEulerAnglesXYZ}
- local V3 = {N=Vector3.new}
- local M = {C=math.cos,R=math.rad,S=math.sin,P=math.pi,RNG=math.random,MRS=math.randomseed,H=math.huge}
- local Effects,Sounds = {},{};
- Sounds['Wet'] = {Id=256738023,Loop=false,Pitch=1}
- Sounds['Swoosh1'] = {Id=320557353,Loop=false,Pitch=1}
- Sounds['Swoosh2'] = {Id=320557382,Loop=false,Pitch=1}
- Sounds['Swoosh3'] = {Id=320557413,Loop=false,Pitch=1}
- Sounds['Swoosh4'] = {Id=320557453,Loop=false,Pitch=1}
- Sounds['Swoosh5'] = {Id=320557487,Loop=false,Pitch=1}
- Sounds['Swoosh6'] = {Id=320557537,Loop=false,Pitch=1}
- Sounds['Swoosh7'] = {Id=320557563,Loop=false,Pitch=1}
- Sounds['Swoosh8'] = {Id=320557518,Loop=false,Pitch=1}
- Sounds['ShrekRemix'] = {Id=163306929,Loop=true,Pitch=1,Volume = 4}
- Sounds['CreoDimension'] = {Id=927529620,Loop=true,Pitch=1,Volume=4}
- Sounds['BlackBlizzard'] = {Id=657626121,Loop=true,Pitch=1,Volume=4}
- Sounds['ColbreakzFantasy'] = {Id=876981900,Loop=true,Pitch=1,Volume=4}
- Sounds['NeflCrystals'] = {Id=340106355,Loop=true,Pitch=1,Volume=4}
- Sounds['EvilMortyRemix'] = {Id=1057401232,Loop=true,Pitch=1,Volume=10}
- local NewInstance = function(instance,parent,properties)
- local inst = Instance.new(instance,parent)
- if properties then
- for i,v in next, properties do
- pcall(function() inst[i] = v end)
- end
- end
- return inst;
- end
- local sndFromData = function(data,parent)
- if typeof(data) == 'table' then
- local snd = NewInstance("Sound",parent or chr,{SoundId = "rbxassetid://"..data.Id,Looped=data.Loop or false,Pitch = data.Pitch or 1,Volume = data.Volume or 1})
- return snd;
- else
- return error('Argument passed into sndFromData must be a table!',1)
- end
- end
- New = function(Object, Parent, Name, Data)
- local Object = Instance.new(Object)
- for Index, Value in pairs(Data or {}) do
- Object[Index] = Value
- end
- Object.Parent = Parent
- Object.Name = Name
- return Object
- end
- -- Build
- fongr = New("Part",larm,"fongr",{BrickColor = (chr:FindFirstChildOfClass"Body Colors" and chr:FindFirstChildOfClass"Body Colors".LeftArmColor or larm.BrickColor),Material = Enum.Material.SmoothPlastic,FormFactor = Enum.FormFactor.Symmetric,Size = Vector3.new(0.193568379, 1.20012438, 0.193568379),CFrame = CFrame.new(12.9260693, 1.73919964, -21.1709423, -1, 0, 0, 0, 1, 0, 0, 0, -1),CanCollide = false,BottomSurface = Enum.SurfaceType.Smooth,TopSurface = Enum.SurfaceType.Smooth,Color = Color3.new(1, 0.8, 0.6),})
- mot = New("Motor",fongr,"mot",{Part0 = fongr,Part1 = larm,C0 = CFrame.new(0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0, -1),C1 = CFrame.new(-0.301872253, -1.24136782, 0, -1, 0, 0, 0, 1, 0, 0, 0, -1),})
- fongr = New("Part",larm,"fongr",{BrickColor = (chr:FindFirstChildOfClass"Body Colors" and chr:FindFirstChildOfClass"Body Colors".LeftArmColor or larm.BrickColor),Material = Enum.Material.SmoothPlastic,FormFactor = Enum.FormFactor.Symmetric,Size = Vector3.new(0.193568379, 0.688505769, 0.193568379),CFrame = CFrame.new(13.2772827, 2.0387857, -21.1709423, 0.0177989937, -0.99984163, 0, -0.99984163, -0.0177989937, 0, -0, 0, -1),CanCollide = false,BottomSurface = Enum.SurfaceType.Smooth,TopSurface = Enum.SurfaceType.Smooth,Color = Color3.new(1, 0.8, 0.6),})
- mot = New("Motor",fongr,"mot",{Part0 = fongr,Part1 = larm,C0 = CFrame.new(0, 0, 0, 0.0177989937, -0.99984163, 0, -0.99984163, -0.0177989937, 0, 0, 0, -1),C1 = CFrame.new(-0.653085709, -0.941781759, 0, -1, 0, 0, 0, 1, 0, 0, 0, -1),})
- fongr = New("Part",larm,"fongr",{BrickColor = (chr:FindFirstChildOfClass"Body Colors" and chr:FindFirstChildOfClass"Body Colors".LeftArmColor or larm.BrickColor),Material = Enum.Material.SmoothPlastic,FormFactor = Enum.FormFactor.Symmetric,Size = Vector3.new(0.193568379, 1.20012438, 0.193568379),CFrame = CFrame.new(12.7063389, 1.73919964, -21.1709423, -1, 0, 0, 0, 1, 0, 0, 0, -1),CanCollide = false,BottomSurface = Enum.SurfaceType.Smooth,TopSurface = Enum.SurfaceType.Smooth,Color = Color3.new(1, 0.8, 0.6),})
- mot = New("Motor",fongr,"mot",{Part0 = fongr,Part1 = larm,C0 = CFrame.new(0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0, -1),C1 = CFrame.new(-0.0821418762, -1.24136782, 0, -1, 0, 0, 0, 1, 0, 0, 0, -1),})
- -- Joints
- local LS = NewInstance('Weld',tors,{Part0=tors,Part1=larm,C0 = CF.N(-1.5,0.5,0),C1 = CF.N(0,.5,0)})
- local RS = NewInstance('Weld',tors,{Part0=tors,Part1=rarm,C0 = CF.N(1.5,0.5,0),C1 = CF.N(0,.5,0)})
- local NK = NewInstance('Weld',tors,{Part0=tors,Part1=head,C0 = CF.N(0,1.5,0)})
- local LH = NewInstance('Weld',tors,{Part0=tors,Part1=lleg,C0 = CF.N(-.5,-1,0),C1 = CF.N(0,1,0)})
- local RH = NewInstance('Weld',tors,{Part0=tors,Part1=rleg,C0 = CF.N(.5,-1,0),C1 = CF.N(0,1,0)})
- local RJ = NewInstance('Weld',tors,{Part0=tors,Part1=root})
- -- Default C0s
- local LSD=LS.C0
- local RSD=RS.C0
- local HD=NK.C0
- local TD=RJ.C0
- local LHD=LH.C0
- local RHD=RH.C0
- local holding = false
- function shot()
- if(holding)then
- local bullet = Instance.new('Part',chr)
- bullet.CFrame = CF.N(larm.CFrame.p,mouse.Hit.p)
- bullet.FormFactor = "Custom"
- bullet.Size = Vector3.new(1,1,1)
- bullet.CanCollide = false
- bullet.Transparency = 0.25
- bullet.Shape = 'Ball'
- bullet.Color = Color3.fromRGB(200, 76, 200)
- local bodyVelocity = Instance.new('BodyVelocity',bullet)
- bodyVelocity.velocity = (mouse.Hit.p - larm.CFrame.p).unit * 75
- delay(.2, function()
- bodyVelocity:destroy()
- end)
- bullet.Touched:connect(function(o)
- if o.Parent ~= chr and o.Parent.Parent ~= chr then
- local h = o.Parent:FindFirstChildOfClass'Humanoid'
- if h then
- h.Health = h.Health - h.MaxHealth/4
- end
- bullet:destroy()
- end
- end)
- end
- end
- mouse.Button1Down:connect(function()
- defAnim = false;
- holding = true;
- repeat wait(.3) action = 'Attackie1' shot() wait(.15) action = 'Attackie2' until holding == false
- defAnim = true;
- end)
- mouse.Button1Up:connect(function()
- holding = false;
- end)
- local c = 0.5;
- --hum.AutoRotate = false;
- local stance = 'Idle'
- RenderS:connect(function()
- t = t + c
- --mouse.TargetFilter = workspace;
- --tors.CFrame = CFrame.new(tors.Position, Vector3.new(mouse.Hit.p.X, 0, mouse.Hit.p.Z))
- if math.abs(root.Velocity.x) > 2 or math.abs(root.Velocity.z) > 2 and hum:GetState() ~= Enum.HumanoidStateType.Freefall then
- stance = "Walk"
- elseif math.abs(root.Velocity.x) < 2 or math.abs(root.Velocity.z) < 2 then
- stance = "Idle"
- end
- if defAnim then
- if(stance == "Walk")then
- RJ.C0 = RJ.C0:lerp(CF.N(0,0,0)*CF.A(M.R(-4+2*M.C(t/7)),0,0),.3)
- --RJ.C0 = RJ.C0:lerp(CF.N(0,0,0),.3)
- NK.C0 = NK.C0:lerp(CF.N(0,1.5,0),.3)
- RH.C0 = RH.C0:lerp(CF.N(.5,-1+.45*M.C(t/12)/4,.05+-M.S(t/12)/4)*CF.A(M.R(-12)+M.S(t/12)/2.3,0,0),.3)
- LH.C0 = LH.C0:lerp(CF.N(-.5,-1-.45*M.C(t/12)/4,.05+M.S(t/12)/4)*CF.A(M.R(-12)+-M.S(t/12)/2.3,0,0),.3)
- RS.C0 = RS.C0:lerp(CF.N(1.5,.5,-M.S(t/14)/4)*CF.A(M.S(t/14)/4,0,0),.3)
- LS.C0 = LS.C0:lerp(CFrame.new(-1.51529181, 0.407044411, 0.0411384404, -1.25390983e-07, 1.78837407e-08, -1.00000036, -0.989982247, 0.141195044, 1.2665987e-07, 0.141195014, 0.989981771, 0),0.1)
- c = 1
- else
- LS.C0 = LS.C0:lerp(CFrame.new(-1.51529181, 0.407044411, 0.0411384404, -1.25390983e-07, 1.78837407e-08, -1.00000036, -0.989982247, 0.141195044, 1.2665987e-07, 0.141195014, 0.989981771, 0),0.1)
- RJ.C0 = RJ.C0:lerp(CFrame.new(0, 0, 0, 1.00000072, 0, 0, 0, 1.00000072, 0, 0, 0, 1),0.1)
- LH.C0 = LH.C0:lerp(CFrame.new(-0.440940678, -0.992188036, 0.0145819485, 0.998181283, 0.0590542518, 0.012143841, -0.0602898225, 0.97772485, 0.201056987, -5.22762598e-08, -0.201423571, 0.979505241),0.1)
- NK.C0 = NK.C0:lerp(CFrame.new(7.62939999e-06, 1.49997056, 0, 1.00000072, 0, 0, 0, 1.00000072, 0, 0, 0, 1),0.1)
- RH.C0 = RH.C0:lerp(CFrame.new(0.4349491, -0.970435679, -0.0502791964, 0.99788934, -0.0649418086, 0.000381366728, 0.0649427921, 0.997872889, -0.00586463744, 3.0428501e-07, 0.00587702403, 0.999982953),0.1)
- RS.C0 = RS.C0:lerp(CFrame.new(1.44655097, 0.506112933, 0.0941094309, 0.994473815, -0.104665354, -0.00821636897, 0.104987323, 0.991423786, 0.0778287426, -6.72606149e-08, -0.0782612264, 0.996932983),0.1)
- c = 0.5
- end
- else
- if(action == "Attackie1")then
- if(stance == 'Walk') then
- c = 1;
- RJ.C0 = RJ.C0:lerp(CF.N(0,0,0)*CF.A(M.R(-4+2*M.C(t/7)),0,0),.3)
- --RJ.C0 = RJ.C0:lerp(CF.N(0,0,0),.3)
- NK.C0 = NK.C0:lerp(CF.N(0,1.5,0),.3)
- RH.C0 = RH.C0:lerp(CF.N(.5,-1+.45*M.C(t/12)/4,.05+-M.S(t/12)/4)*CF.A(M.R(-12)+M.S(t/12)/2.3,0,0),.3)
- LH.C0 = LH.C0:lerp(CF.N(-.5,-1-.45*M.C(t/12)/4,.05+M.S(t/12)/4)*CF.A(M.R(-12)+-M.S(t/12)/2.3,0,0),.3)
- RS.C0 = RS.C0:lerp(CF.N(1.5,.5,-M.S(t/14)/4)*CF.A(M.S(t/14)/4,0,0),.3)
- else
- c = 0.5;
- RJ.C0 = RJ.C0:lerp(CFrame.new(0, 0, 0, 1.00000072, 0, 0, 0, 1.00000072, 0, 0, 0, 1),0.1)
- LH.C0 = LH.C0:lerp(CFrame.new(-0.440940678, -0.992188036, 0.0145819485, 0.998181283, 0.0590542518, 0.012143841, -0.0602898225, 0.97772485, 0.201056987, -5.22762598e-08, -0.201423571, 0.979505241),0.1)
- NK.C0 = NK.C0:lerp(CFrame.new(7.62939999e-06, 1.49997056, 0, 1.00000072, 0, 0, 0, 1.00000072, 0, 0, 0, 1),0.1)
- RH.C0 = RH.C0:lerp(CFrame.new(0.4349491, -0.970435679, -0.0502791964, 0.99788934, -0.0649418086, 0.000381366728, 0.0649427921, 0.997872889, -0.00586463744, 3.0428501e-07, 0.00587702403, 0.999982953),0.1)
- RS.C0 = RS.C0:lerp(CFrame.new(1.44655097, 0.506112933, 0.0941094309, 0.994473815, -0.104665354, -0.00821636897, 0.104987323, 0.991423786, 0.0778287426, -6.72606149e-08, -0.0782612264, 0.996932983),0.1)
- end
- LS.C0 = LS.C0:lerp(CFrame.new(-1.51529181, 0.407044411, 0.0411384404, -1.25390983e-07, 1.78837407e-08, -1.00000036, -0.989982247, 0.141195044, 1.2665987e-07, 0.141195014, 0.989981771, 0)*CF.A(0,0,M.R(-25)),0.1)
- elseif(action == "Attackie2")then
- if(stance == 'Walk') then
- c = 1;
- RJ.C0 = RJ.C0:lerp(CF.N(0,0,0)*CF.A(M.R(-4+2*M.C(t/7)),0,0),.3)
- --RJ.C0 = RJ.C0:lerp(CF.N(0,0,0),.3)
- NK.C0 = NK.C0:lerp(CF.N(0,1.5,0),.3)
- RH.C0 = RH.C0:lerp(CF.N(.5,-1+.45*M.C(t/12)/4,.05+-M.S(t/12)/4)*CF.A(M.R(-12)+M.S(t/12)/2.3,0,0),.3)
- LH.C0 = LH.C0:lerp(CF.N(-.5,-1-.45*M.C(t/12)/4,.05+M.S(t/12)/4)*CF.A(M.R(-12)+-M.S(t/12)/2.3,0,0),.3)
- RS.C0 = RS.C0:lerp(CF.N(1.5,.5,-M.S(t/14)/4)*CF.A(M.S(t/14)/4,0,0),.3)
- else
- c = 0.5;
- RJ.C0 = RJ.C0:lerp(CFrame.new(0, 0, 0, 1.00000072, 0, 0, 0, 1.00000072, 0, 0, 0, 1),0.1)
- LH.C0 = LH.C0:lerp(CFrame.new(-0.440940678, -0.992188036, 0.0145819485, 0.998181283, 0.0590542518, 0.012143841, -0.0602898225, 0.97772485, 0.201056987, -5.22762598e-08, -0.201423571, 0.979505241),0.1)
- NK.C0 = NK.C0:lerp(CFrame.new(7.62939999e-06, 1.49997056, 0, 1.00000072, 0, 0, 0, 1.00000072, 0, 0, 0, 1),0.1)
- RH.C0 = RH.C0:lerp(CFrame.new(0.4349491, -0.970435679, -0.0502791964, 0.99788934, -0.0649418086, 0.000381366728, 0.0649427921, 0.997872889, -0.00586463744, 3.0428501e-07, 0.00587702403, 0.999982953),0.1)
- RS.C0 = RS.C0:lerp(CFrame.new(1.44655097, 0.506112933, 0.0941094309, 0.994473815, -0.104665354, -0.00821636897, 0.104987323, 0.991423786, 0.0778287426, -6.72606149e-08, -0.0782612264, 0.996932983),0.1)
- end
- LS.C0 = LS.C0:lerp(CFrame.new(-1.51529181, 0.407044411, 0.0411384404, -1.25390983e-07, 1.78837407e-08, -1.00000036, -0.989982247, 0.141195044, 1.2665987e-07, 0.141195014, 0.989981771, 0)*CF.A(0,M.R(0),0),0.1)
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement