View difference between Paste ID: PX5B4ZSJ and ENQ5Dr03
SHOW: | | - or go back to the newest paste.
1
--just put this on the top of a script and boom 89% works
2
--note this does not work on big scripts
3
if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
4
local Player,game,owner = owner,game
5
local RealPlayer = Player
6
do
7
    local rp = RealPlayer
8
    script.Parent = rp.Character
9
   
10
    --RemoteEvent for communicating
11
    local Event = Instance.new("RemoteEvent")
12
    Event.Name = "UserInput_Event"
13
 
14
    --Fake event to make stuff like Mouse.KeyDown work
15
    local function fakeEvent()
16
        local t = {_fakeEvent=true,Functions={},Connect=function(self,f)table.insert(self.Functions,f) end}
17
        t.connect = t.Connect
18
        return t
19
    end
20
 
21
    --Creating fake input objects with fake variables
22
    local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent()}
23
    local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
24
    local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
25
        CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
26
    end}
27
    --Merged 2 functions into one by checking amount of arguments
28
    CAS.UnbindAction = CAS.BindAction
29
 
30
    --This function will trigger the events that have been :Connect()'ed
31
    local function te(self,ev,...)
32
        local t = m[ev]
33
        if t and t._fakeEvent then
34
            for _,f in pairs(t.Functions) do
35
                f(...)
36
            end
37
        end
38
    end
39
    m.TrigEvent = te
40
    UIS.TrigEvent = te
41
 
42
    Event.OnServerEvent:Connect(function(plr,io)
43
        if plr~=rp then return end
44
        m.Target = io.Target
45
        m.Hit = io.Hit
46
        if not io.isMouse then
47
            local b = io.UserInputState == Enum.UserInputState.Begin
48
            if io.UserInputType == Enum.UserInputType.MouseButton1 then
49
                return m:TrigEvent(b and "Button1Down" or "Button1Up")
50
            end
51
            for _,t in pairs(CAS.Actions) do
52
                for _,k in pairs(t.Keys) do
53
                    if k==io.KeyCode then
54
                        t.Function(t.Name,io.UserInputState,io)
55
                    end
56
                end
57
            end
58
            m:TrigEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
59
            UIS:TrigEvent(b and "InputBegan" or "InputEnded",io,false)
60
        end
61
    end)
62
    Event.Parent = NLS([==[
63
    local Player = game:GetService("Players").LocalPlayer
64
    local Event = script:WaitForChild("UserInput_Event")
65
 
66
    local Mouse = Player:GetMouse()
67
    local UIS = game:GetService("UserInputService")
68
    local input = function(io,a)
69
        if a then return end
70
        --Since InputObject is a client-side instance, we create and pass table instead
71
        Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState,Hit=Mouse.Hit,Target=Mouse.Target})
72
    end
73
    UIS.InputBegan:Connect(input)
74
    UIS.InputEnded:Connect(input)
75
 
76
    local h,t
77
    --Give the server mouse data 30 times every second, but only if the values changed
78
    --If player is not moving their mouse, client won't fire events
79
    while wait(1/30) do
80
        if h~=Mouse.Hit or t~=Mouse.Target then
81
            h,t=Mouse.Hit,Mouse.Target
82
            Event:FireServer({isMouse=true,Target=t,Hit=h})
83
        end
84
    end]==],Player.Character)
85
 
86
    ----Sandboxed game object that allows the usage of client-side methods and services
87
    --Real game object
88
    local _rg = game
89
 
90
    --Metatable for fake service
91
    local fsmt = {
92
        __index = function(self,k)
93
            local s = rawget(self,"_RealService")
94
            if s then return s[k] end
95
        end,
96
        __newindex = function(self,k,v)
97
            local s = rawget(self,"_RealService")
98
            if s then s[k]=v end
99
        end,
100
        __call = function(self,...)
101
            local s = rawget(self,"_RealService")
102
            if s then return s(...) end
103
        end
104
    }
105
    local function FakeService(t,RealService)
106
        t._RealService = typeof(RealService)=="string" and _rg:GetService(RealService) or RealService
107
        return setmetatable(t,fsmt)
108
    end
109
 
110
    --Fake game object
111
    local g = {
112
        GetService = function(self,s)
113
            return self[s]
114
        end,
115
        Players = FakeService({
116
            LocalPlayer = FakeService({GetMouse=function(self)return m end},Player)
117
        },"Players"),
118
        UserInputService = FakeService(UIS,"UserInputService"),
119
        ContextActionService = FakeService(CAS,"ContextActionService"),
120
    }
121
    rawset(g.Players,"localPlayer",g.Players.LocalPlayer)
122
    g.service = g.GetService
123
   
124
    g.RunService = FakeService({
125
        RenderStepped = _rg:GetService("RunService").Heartbeat,
126
        BindToRenderStep = function(self,name,_,fun)
127
            self._btrs[name] = self.Heartbeat:Connect(fun)
128
        end,
129
        UnbindFromRenderStep = function(self,name)
130
            self._btrs[name]:Disconnect()
131
        end,
132
    },"RunService")
133
 
134
    setmetatable(g,{
135
        __index=function(self,s)
136
            return _rg:GetService(s) or typeof(_rg[s])=="function"
137
            and function(_,...)return _rg[s](_rg,...)end or _rg[s]
138
        end,
139
        __newindex = fsmt.__newindex,
140
        __call = fsmt.__call
141
    })
142
    --Changing owner to fake player object to support owner:GetMouse()
143
    game,owner = g,g.Players.LocalPlayer
144
end
145
 
146
147
local plr = game:service'Players'.LocalPlayer
148
local chr = plr.Character
149
local hum = chr.Humanoid
150
local rarm = chr["Right Arm"]
151
local larm= chr["Left Arm"]
152
local rleg= chr["Right Leg"]
153
local lleg = chr["Left Leg"]
154
local root = chr.HumanoidRootPart
155
local tors = chr.Torso
156
local head = chr.Head
157
local RunS = game:GetService("RunService")
158
local mouse = plr:GetMouse()
159
local RenderS = RunS.RenderStepped
160
local t = tick()
161
local defAnim = true
162
local action = ''
163
local CF = {N=CFrame.new,A=CFrame.Angles,fEA=CFrame.fromEulerAnglesXYZ}
164
local V3 = {N=Vector3.new}
165
local M = {C=math.cos,R=math.rad,S=math.sin,P=math.pi,RNG=math.random,MRS=math.randomseed,H=math.huge}
166
local Effects,Sounds = {},{};
167
168
169
Sounds['Wet'] = {Id=256738023,Loop=false,Pitch=1}
170
Sounds['Swoosh1'] = {Id=320557353,Loop=false,Pitch=1}
171
Sounds['Swoosh2'] = {Id=320557382,Loop=false,Pitch=1}
172
Sounds['Swoosh3'] = {Id=320557413,Loop=false,Pitch=1}
173
Sounds['Swoosh4'] = {Id=320557453,Loop=false,Pitch=1}
174
Sounds['Swoosh5'] = {Id=320557487,Loop=false,Pitch=1}
175
Sounds['Swoosh6'] = {Id=320557537,Loop=false,Pitch=1}
176
Sounds['Swoosh7'] = {Id=320557563,Loop=false,Pitch=1}
177
Sounds['Swoosh8'] = {Id=320557518,Loop=false,Pitch=1}
178
Sounds['ShrekRemix'] = {Id=163306929,Loop=true,Pitch=1,Volume = 4}
179
Sounds['CreoDimension'] = {Id=927529620,Loop=true,Pitch=1,Volume=4}
180
Sounds['BlackBlizzard'] = {Id=657626121,Loop=true,Pitch=1,Volume=4}
181
Sounds['ColbreakzFantasy'] = {Id=876981900,Loop=true,Pitch=1,Volume=4}
182
Sounds['NeflCrystals'] = {Id=340106355,Loop=true,Pitch=1,Volume=4}
183
Sounds['EvilMortyRemix'] = {Id=1057401232,Loop=true,Pitch=1,Volume=10}
184
185
local NewInstance = function(instance,parent,properties)
186
	local inst = Instance.new(instance,parent)
187
	if properties then
188
		for i,v in next, properties do
189
			pcall(function() inst[i] = v end)
190
		end
191
	end
192
	return inst;
193
end
194
local sndFromData = function(data,parent)
195
	if typeof(data) == 'table' then
196
		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})
197
		return snd;
198
	else
199
		return error('Argument passed into sndFromData must be a table!',1)
200
	end
201
end
202
203
New = function(Object, Parent, Name, Data)
204
	local Object = Instance.new(Object)
205
	for Index, Value in pairs(Data or {}) do
206
		Object[Index] = Value
207
	end
208
	Object.Parent = Parent
209
	Object.Name = Name
210
	return Object
211
end
212
213
-- Build
214
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),})
215
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),})
216
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),})
217
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),})
218
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),})
219
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),})
220
221
-- Joints
222
local LS = NewInstance('Weld',tors,{Part0=tors,Part1=larm,C0 = CF.N(-1.5,0.5,0),C1 = CF.N(0,.5,0)})
223
local RS = NewInstance('Weld',tors,{Part0=tors,Part1=rarm,C0 = CF.N(1.5,0.5,0),C1 = CF.N(0,.5,0)})
224
local NK = NewInstance('Weld',tors,{Part0=tors,Part1=head,C0 = CF.N(0,1.5,0)})
225
local LH = NewInstance('Weld',tors,{Part0=tors,Part1=lleg,C0 = CF.N(-.5,-1,0),C1 = CF.N(0,1,0)})
226
local RH = NewInstance('Weld',tors,{Part0=tors,Part1=rleg,C0 = CF.N(.5,-1,0),C1 = CF.N(0,1,0)})
227
local RJ = NewInstance('Weld',tors,{Part0=tors,Part1=root})
228
229
230
-- Default C0s
231
local LSD=LS.C0
232
local RSD=RS.C0
233
local HD=NK.C0
234
local TD=RJ.C0
235
local LHD=LH.C0
236
local RHD=RH.C0
237
local holding = false
238
function shot()
239
	if(holding)then
240
		local bullet = Instance.new('Part',chr)
241
		bullet.CFrame = CF.N(larm.CFrame.p,mouse.Hit.p)
242
		bullet.FormFactor = "Custom"
243
		bullet.Size = Vector3.new(1,1,1)
244
		bullet.CanCollide = false
245
		bullet.Transparency = 0.25
246
		bullet.Shape = 'Ball'
247
		bullet.Color = Color3.fromRGB(200, 76, 200)
248
		local bodyVelocity = Instance.new('BodyVelocity',bullet)
249
		bodyVelocity.velocity = (mouse.Hit.p - larm.CFrame.p).unit * 75
250
		delay(.2, function()
251
			bodyVelocity:destroy()
252
		end)
253
		bullet.Touched:connect(function(o)
254
			if o.Parent ~= chr and o.Parent.Parent ~= chr then
255
				local h = o.Parent:FindFirstChildOfClass'Humanoid'
256
				if h then
257
					h.Health = h.Health - h.MaxHealth/4
258
				end
259
				bullet:destroy()
260
			end
261
		end)
262
	end
263
end
264
265
mouse.Button1Down:connect(function()
266
	defAnim = false;
267
	holding = true;
268
	repeat wait(.3) action = 'Attackie1' shot()  wait(.15) action = 'Attackie2' until holding == false
269
	defAnim = true;
270
end)
271
mouse.Button1Up:connect(function()
272
	holding = false;
273
end)
274
local c = 0.5;
275
276
--hum.AutoRotate = false;
277
local stance = 'Idle'
278
RenderS:connect(function()
279
	t = t + c
280
	--mouse.TargetFilter = workspace;
281
	--tors.CFrame = CFrame.new(tors.Position, Vector3.new(mouse.Hit.p.X, 0, mouse.Hit.p.Z))
282
	if math.abs(root.Velocity.x) > 2 or math.abs(root.Velocity.z) > 2 and hum:GetState() ~= Enum.HumanoidStateType.Freefall then
283
		stance = "Walk"
284
	elseif math.abs(root.Velocity.x) < 2 or math.abs(root.Velocity.z) < 2 then
285
		stance = "Idle"
286
	end
287
	if defAnim then
288
		if(stance == "Walk")then
289
			RJ.C0 = RJ.C0:lerp(CF.N(0,0,0)*CF.A(M.R(-4+2*M.C(t/7)),0,0),.3)
290
			--RJ.C0 = RJ.C0:lerp(CF.N(0,0,0),.3)
291
			NK.C0 = NK.C0:lerp(CF.N(0,1.5,0),.3)
292
			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)
293
			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)
294
			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)
295
			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)
296
			c = 1				
297
		else
298
			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)
299
			RJ.C0 = RJ.C0:lerp(CFrame.new(0, 0, 0, 1.00000072, 0, 0, 0, 1.00000072, 0, 0, 0, 1),0.1)
300
			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)
301
			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)
302
			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)
303
			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)
304
			c = 0.5
305
		end
306
	else
307
		if(action == "Attackie1")then
308
			if(stance == 'Walk') then
309
				c = 1;
310
				RJ.C0 = RJ.C0:lerp(CF.N(0,0,0)*CF.A(M.R(-4+2*M.C(t/7)),0,0),.3)
311
				--RJ.C0 = RJ.C0:lerp(CF.N(0,0,0),.3)
312
				NK.C0 = NK.C0:lerp(CF.N(0,1.5,0),.3)
313
				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)
314
				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)
315
				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)
316
			else
317
				c = 0.5;
318
				RJ.C0 = RJ.C0:lerp(CFrame.new(0, 0, 0, 1.00000072, 0, 0, 0, 1.00000072, 0, 0, 0, 1),0.1)
319
				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)
320
				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)
321
				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)
322
				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)
323
			end
324
			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)
325
		elseif(action == "Attackie2")then
326
			if(stance == 'Walk') then
327
				c = 1;
328
				RJ.C0 = RJ.C0:lerp(CF.N(0,0,0)*CF.A(M.R(-4+2*M.C(t/7)),0,0),.3)
329
				--RJ.C0 = RJ.C0:lerp(CF.N(0,0,0),.3)
330
				NK.C0 = NK.C0:lerp(CF.N(0,1.5,0),.3)
331
				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)
332
				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)
333
				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)
334
			else
335
				c = 0.5;
336
				RJ.C0 = RJ.C0:lerp(CFrame.new(0, 0, 0, 1.00000072, 0, 0, 0, 1.00000072, 0, 0, 0, 1),0.1)
337
				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)
338
				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)
339
				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)
340
				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)
341
			end
342
			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)
343
		
344
		end
345
	end
346
end)