SHOW:
|
|
- or go back to the newest paste.
1 | --https://github.com/Mokiros/roblox-FE-compatibility | |
2 | if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end | |
3 | local Player,Mouse,mouse,UserInputService,ContextActionService = owner | |
4 | local RealPlayer = Player | |
5 | do print("FE Compatibility code by Mokiros")local a=RealPlayer;script.Parent=a.Character;local b=Instance.new("RemoteEvent")b.Name="UserInput_Event"local function c()local d={_fakeEvent=true,Functions={},Connect=function(self,e)table.insert(self.Functions,e)end}d.connect=d.Connect;return d end;local f={Target=nil,Hit=CFrame.new(),KeyUp=c(),KeyDown=c(),Button1Up=c(),Button1Down=c(),Button2Up=c(),Button2Down=c()}local g={InputBegan=c(),InputEnded=c()}local CAS={Actions={},BindAction=function(self,h,i,j,...)CAS.Actions[h]=i and{Name=h,Function=i,Keys={...}}or nil end}CAS.UnbindAction=CAS.BindAction;local function k(self,l,...)local d=f[l]if d and d._fakeEvent then for m,e in pairs(d.Functions)do e(...)end end end;f.TrigEvent=k;g.TrigEvent=k;b.OnServerEvent:Connect(function(n,o)if n~=a then return end;f.Target=o.Target;f.Hit=o.Hit;if not o.isMouse then local p=o.UserInputState==Enum.UserInputState.Begin;if o.UserInputType==Enum.UserInputType.MouseButton1 then return f:TrigEvent(p and"Button1Down"or"Button1Up")end;if o.UserInputType==Enum.UserInputType.MouseButton2 then return f:TrigEvent(p and"Button2Down"or"Button2Up")end;for m,d in pairs(CAS.Actions)do for m,q in pairs(d.Keys)do if q==o.KeyCode then d.Function(d.Name,o.UserInputState,o)end end end;f:TrigEvent(p and"KeyDown"or"KeyUp",o.KeyCode.Name:lower())g:TrigEvent(p and"InputBegan"or"InputEnded",o,false)end end)b.Parent=NLS([==[local a=game:GetService("Players").LocalPlayer;local b=script:WaitForChild("UserInput_Event")local c=a:GetMouse()local d=game:GetService("UserInputService")local e=function(f,g)if g then return end;b:FireServer({KeyCode=f.KeyCode,UserInputType=f.UserInputType,UserInputState=f.UserInputState,Hit=c.Hit,Target=c.Target})end;d.InputBegan:Connect(e)d.InputEnded:Connect(e)local h,i;while wait(1/30)do if h~=c.Hit or i~=c.Target then h,i=c.Hit,c.Target;b:FireServer({isMouse=true,Target=i,Hit=h})end end]==],Player.Character)local r=game;local s={__index=function(self,q)local t=rawget(self,"_RealService")if t then return typeof(t[q])=="function"and function(m,...)return t[q](t,...)end or t[q]end end,__newindex=function(self,q,u)local t=rawget(self,"_RealService")if t then t[q]=u end end}local function v(d,w)d._RealService=typeof(w)=="string"and r:GetService(w)or w;return setmetatable(d,s)end;local x={GetService=function(self,t)return rawget(self,t)or r:GetService(t)end,Players=v({LocalPlayer=v({GetMouse=function(self)return f end},Player)},"Players"),UserInputService=v(g,"UserInputService"),ContextActionService=v(CAS,"ContextActionService"),RunService=v({_btrs={},RenderStepped=r:GetService("RunService").Heartbeat,BindToRenderStep=function(self,h,m,i)self._btrs[h]=self.Heartbeat:Connect(i)end,UnbindFromRenderStep=function(self,h)self._btrs[h]:Disconnect()end},"RunService")}rawset(x.Players,"localPlayer",x.Players.LocalPlayer)x.service=x.GetService;v(x,game)game,owner=x,x.Players.LocalPlayer end | |
6 | --[[ | |
7 | Smith and Wesson M&P 45, chambered in .45 ACP ammunition. | |
8 | The standard magazine holds 10 rounds, although magazines that could hold 14 rounds were also made but looked incredibly stupid. | |
9 | Credit to litozinnamon for the crosshairs and bullethole decals. I used them without permission. Not like I asked him, anyhow. | |
10 | ]] | |
11 | ||
12 | plr=game:service'Players'.LocalPlayer | |
13 | ch,char=plr.Character,plr.Character | |
14 | hum=ch.Humanoid | |
15 | tor,torso,rootpart,rj=ch.Torso,ch.Torso,ch.HumanoidRootPart,ch.HumanoidRootPart.RootJoint | |
16 | m,mouse=plr:GetMouse(),plr:GetMouse() | |
17 | cfn,ang,mr,int=CFrame.new,CFrame.Angles,math.rad,Instance.new | |
18 | bc=BrickColor.new | |
19 | head=ch.Head | |
20 | cam=workspace.CurrentCamera | |
21 | ||
22 | rj.C0=cfn() | |
23 | rj.C1=cfn() | |
24 | ||
25 | sheathed=false | |
26 | jammed=false | |
27 | ||
28 | ||
29 | ||
30 | ||
31 | ||
32 | ||
33 | ||
34 | ||
35 | ||
36 | ||
37 | ||
38 | local minimumsize = Vector3.new(0.7,0.7,0.7) --Minimumsize for a part to get divided,higher numbers = less detailed and bigger/less bricks | |
39 | local surface_between_splitted_parts = 'SmoothNoOutlines' --the surface between splitted parts | |
40 | --local fragmented = workspace:FindFirstChild("Fragmented") | |
41 | local fragmentable = workspace --all fragmentable objects should be stored in here | |
42 | local list = {} | |
43 | local brickcount = 0 | |
44 | --local m = Instance.new("Hint",workspace) | |
45 | local storage = {} | |
46 | local fillup = 1000 --it constantly generates new parts until it reaches this number(hacky way to prevent lagspikes if there is a large explosion),change it to 0 if you don´t want it to generate (useless) parts. | |
47 | local maximumstorage = 2000 --it will recycle parts if the number of parts in the storage doesnt exceed this number | |
48 | local storage_position = Vector3.new(0,0,5000) --place them somewhere off the map | |
49 | local stored_partsize = Vector3.new(1,1,1) --make them small | |
50 | local parts_created_per_frame = 5 --number of parts being created per frame to fill up the storage | |
51 | ||
52 | ||
53 | function fragmentate(cframe,size,color,explosion_position,explosion_blastradius,backsurface,bottomsurface,frontsurface,leftsurface,rightsurface,topsurface,transparency,reflectance) | |
54 | local xi = size.X >= minimumsize.X*(1+explosion_blastradius/16) and 2 or 1 --to reduce the lagg in large explosions we increase minimumsize based on the explosionradius... | |
55 | local yi = size.Y >= minimumsize.Y*(1+explosion_blastradius/16) and 2 or 1 | |
56 | local zi = size.Z >= minimumsize.Z*(1+explosion_blastradius/16) and 2 or 1 | |
57 | if xi == 1 and yi == 1 and zi == 1 or (cframe.p-explosion_position).magnitude > size.magnitude/2 + explosion_blastradius then --don´t fragmentate parts, that are too small to fragmentate or too far away from the explosion | |
58 | if xi == 1 and yi == 1 and zi == 1 then return end --optional | |
59 | if #storage > 0 then | |
60 | local p = storage[1] | |
61 | p.BrickColor = color | |
62 | p.Size = size | |
63 | p.BackSurface = backsurface | |
64 | p.BottomSurface = bottomsurface | |
65 | p.FrontSurface = frontsurface | |
66 | p.LeftSurface = leftsurface | |
67 | p.RightSurface = rightsurface | |
68 | p.TopSurface = topsurface | |
69 | p.Transparency = transparency | |
70 | p.CFrame = cframe | |
71 | p.Reflectance = reflectance | |
72 | table.remove(storage,1) | |
73 | else | |
74 | local p = Instance.new("Part",fragmentable) | |
75 | p.BrickColor = color | |
76 | p.FormFactor = "Custom" | |
77 | p.Size = size | |
78 | p.BackSurface = backsurface | |
79 | p.BottomSurface = bottomsurface | |
80 | p.FrontSurface = frontsurface | |
81 | p.LeftSurface = leftsurface | |
82 | p.RightSurface = rightsurface | |
83 | p.TopSurface = topsurface | |
84 | p.Transparency = transparency | |
85 | if p.Transparency>0.285 then | |
86 | p.Anchored = false | |
87 | else | |
88 | p.Anchored=true | |
89 | p.Material='Wood' | |
90 | end | |
91 | p.CFrame = cframe | |
92 | p.Reflectance = reflectance | |
93 | end | |
94 | --p:MakeJoints() | |
95 | -- m.Text = m.Text+1 | |
96 | return --stop the function | |
97 | end | |
98 | local mody = math.random(-125,125)/1000 --some randomization | |
99 | for y = 1,yi do | |
100 | if math.random()> 0.5 then | |
101 | local modx = math.random(-125,125)/1000 | |
102 | for x = 1,xi do | |
103 | local modz = math.random(-125,125)/1000 | |
104 | for z = 1,zi do --offset = x/xi-0.75+modx) | |
105 | fragmentate(cframe*CFrame.new(size.X*(xi==1 and 0 or x/xi-0.75+modx),size.Y*(yi==1 and 0 or y/yi-0.75+mody),size.Z*(zi==1 and 0 or z/zi-0.75+modz)), --maths | |
106 | Vector3.new(xi == 2 and size.X*(1-2*math.abs(x/xi-0.75+modx)) or size.X,yi == 2 and size.Y*(1-2*math.abs(y/yi-0.75+mody)) or size.Y, | |
107 | zi == 2 and size.Z*(1-2*math.abs(z/zi-0.75+modz)) or size.Z or agent767_was_here),color,explosion_position,explosion_blastradius, | |
108 | z~=zi and surface_between_splitted_parts or backsurface,y==2 and surface_between_splitted_parts or bottomsurface, | |
109 | z==2 and surface_between_splitted_parts or frontsurface,x==2 and surface_between_splitted_parts or leftsurface,x~=xi and surface_between_splitted_parts or rightsurface, | |
110 | y~=yi and surface_between_splitted_parts or topsurface,transparency,reflectance) | |
111 | end | |
112 | ||
113 | end | |
114 | else | |
115 | local modz = math.random(-125,125)/1000 | |
116 | for z = 1,zi do | |
117 | local modx = math.random(-125,125)/1000 | |
118 | for x = 1,xi do | |
119 | fragmentate(cframe*CFrame.new(size.X*(xi==1 and 0 or x/xi-0.75+modx),size.Y*(yi==1 and 0 or y/yi-0.75+mody),size.Z*(zi==1 and 0 or z/zi-0.75+modz)), | |
120 | Vector3.new(xi == 2 and size.X*(1-2*math.abs(x/xi-0.75+modx)) or size.X,yi == 2 and size.Y*(1-2*math.abs(y/yi-0.75+mody)) or size.Y, | |
121 | zi == 2 and size.Z*(1-2*math.abs(z/zi-0.75+modz)) or size.Z),color,explosion_position,explosion_blastradius, | |
122 | z~=zi and surface_between_splitted_parts or backsurface,y==2 and surface_between_splitted_parts or bottomsurface, | |
123 | z==2 and surface_between_splitted_parts or frontsurface,x==2 and surface_between_splitted_parts or leftsurface,x~=xi and surface_between_splitted_parts or rightsurface, | |
124 | y~=yi and surface_between_splitted_parts or topsurface,transparency,reflectance) | |
125 | end | |
126 | end | |
127 | end | |
128 | end | |
129 | end | |
130 | ||
131 | function start_fragmentation(position,radius) | |
132 | local search = Region3.new(position-Vector3.new(radius,radius,radius)*1.1,position+Vector3.new(radius,radius,radius)*1.1) | |
133 | repeat | |
134 | local finish = false | |
135 | local parts = workspace:FindPartsInRegion3WithIgnoreList(search,list,100) --maximum number of parts that FindPartsInRegion3 can find is 100, so we have to do this to find them all | |
136 | for i = 1,#parts do | |
137 | table.insert(list,1,parts[i]) | |
138 | end | |
139 | finish = true | |
140 | until #parts < 100 and finish | |
141 | print(#list) | |
142 | local t = tick() | |
143 | for i = 1,#list do | |
144 | local p = list[i] | |
145 | if p:IsDescendantOf(fragmentable) and p:GetMass()<3000 and p.Transparency>0.285 and p.Name~='Base' and p:IsDescendantOf(ch)==false then | |
146 | fragmentate(p.CFrame,p.Size,p.BrickColor,position,radius,p.BackSurface,p.BottomSurface,p.FrontSurface,p.LeftSurface,p.RightSurface,p.TopSurface,p.Transparency,p.Reflectance) | |
147 | if #storage < maximumstorage and p.Shape == "Block" then --recycle them | |
148 | p.Anchored = false | |
149 | p.FormFactor = "Custom" | |
150 | p.Size = stored_partsize | |
151 | p.Position = storage_position | |
152 | table.insert(storage,1,p) | |
153 | else --storage is full | |
154 | p:Destroy() | |
155 | end | |
156 | -- m.Text = m.Text-1 | |
157 | end | |
158 | if p:IsDescendantOf(fragmentable) and p:GetMass()<53000 and p.Transparency<0.05 and p.Name~='Base' and tostring(p.Material)=='Enum.Material.Wood' and p:IsDescendantOf(ch)==false then | |
159 | fragmentate(p.CFrame,p.Size,p.BrickColor,position,radius,p.BackSurface,p.BottomSurface,p.FrontSurface,p.LeftSurface,p.RightSurface,p.TopSurface,p.Transparency,p.Reflectance) | |
160 | if #storage < maximumstorage and p.Shape == "Block" then --recycle them | |
161 | p.Anchored = true | |
162 | p.Material='Wood' | |
163 | p.FormFactor = "Custom" | |
164 | p.Size = stored_partsize | |
165 | p.Position = storage_position | |
166 | table.insert(storage,1,p) | |
167 | else --storage is full | |
168 | p:Destroy() | |
169 | end | |
170 | -- m.Text = m.Text-1 | |
171 | end | |
172 | end | |
173 | list = {} | |
174 | -- print(tick()-t) | |
175 | end | |
176 | ||
177 | --[[ | |
178 | spawn(function() | |
179 | while wait() do --oh noes,a loop! So inefficient! | |
180 | if #storage < fillup then | |
181 | for i = 1, parts_created_per_frame do --creates parts to fill up the storage | |
182 | local p = Instance.new("Part",fragmentable) | |
183 | p.Anchored = false | |
184 | p.FormFactor = "Custom" | |
185 | p.Size = stored_partsize | |
186 | p.Position = storage_position | |
187 | table.insert(storage,1,p) | |
188 | end | |
189 | end | |
190 | end | |
191 | end) | |
192 | ]] | |
193 | ||
194 | ||
195 | ||
196 | ||
197 | ||
198 | ||
199 | ||
200 | ||
201 | ||
202 | ||
203 | ||
204 | ||
205 | ||
206 | ||
207 | ||
208 | ||
209 | ||
210 | ||
211 | ||
212 | ||
213 | ||
214 | ||
215 | ||
216 | --local blankn=22416261 | |
217 | ||
218 | --172121567 | |
219 | ||
220 | crosshairs={ | |
221 | {38140824}; | |
222 | {38140833}; | |
223 | {38140839}; | |
224 | {38140843}; | |
225 | {38140852}; | |
226 | {38140910}; | |
227 | {38140915}; | |
228 | {38140923}; | |
229 | {38140928}; | |
230 | {38140931}; | |
231 | {38208259}; | |
232 | {38208275}; | |
233 | {38208284}; | |
234 | {38208303}; | |
235 | {38208310}; | |
236 | {38208325}; | |
237 | {38208330}; | |
238 | {38208352}; | |
239 | {38208359}; | |
240 | {38208377} | |
241 | } | |
242 | ||
243 | bulletholes={ | |
244 | 172274695; | |
245 | 172274721 | |
246 | } | |
247 | ||
248 | for _,v in pairs(crosshairs) do | |
249 | game:service'ContentProvider':Preload('rbxassetid://' .. tostring(v[1]-1)) | |
250 | end | |
251 | ||
252 | currentIco=2 | |
253 | switchIco=function(num) | |
254 | if num<20 then | |
255 | else | |
256 | num=20 | |
257 | end | |
258 | mouse.Icon='rbxassetid://' .. tostring(crosshairs[num][1]-1) | |
259 | currentIco=num | |
260 | end | |
261 | ||
262 | switchIco(currentIco) | |
263 | ||
264 | heldDown=false | |
265 | ||
266 | spreadint=1 | |
267 | --[[Settings]]-- | |
268 | recoil=false -- Set to true for added realism | |
269 | magCapacity=20 -- How much a magazine can hold at once | |
270 | magAmmo=20 -- How much ammo is in the mag | |
271 | crosshairSpread=5 | |
272 | spread=1 | |
273 | pAmmunition=true -- more damage if true | |
274 | ||
275 | ||
276 | jamRate=500 -- How often the gun jams(the more the less) (no less than 1) | |
277 | ||
278 | primaryColor='Really black' | |
279 | secondaryColor='Really black' | |
280 | ||
281 | slideReflectance=0.01 | |
282 | slideMaterial='Plastic' | |
283 | ||
284 | --[[Attachments]]-- | |
285 | ||
286 | silencer=true | |
287 | highCapMag=false -- High capacity magazine | |
288 | laser=true | |
289 | automatic=false | |
290 | grip=true | |
291 | ||
292 | ||
293 | getSound=function(id) | |
294 | game:service'ContentProvider':Preload('rbxassetid'..tostring(id)) | |
295 | local s=int("Sound",ch.Head) | |
296 | s.SoundId='rbxassetid://' .. tostring(id) | |
297 | s.Volume=1 | |
298 | return s | |
299 | end | |
300 | ||
301 | local fireSound=getSound(151997297--[[10209842]]) | |
302 | fireSound.Pitch=1.3 | |
303 | --1.8 | |
304 | ||
305 | local releaseSound=getSound(10209813) | |
306 | releaseSound.Pitch=4 | |
307 | ||
308 | local reloadSound=getSound(10209636) | |
309 | reloadSound.Pitch=3 | |
310 | ||
311 | local magazinelockSound=getSound(152206337) | |
312 | magazinelockSound.Pitch=1.4 | |
313 | ||
314 | local slideBackSound=getSound(152206263) | |
315 | slideBackSound.Pitch=2.5 | |
316 | ||
317 | local slideForwardSound=getSound(152206302) | |
318 | slideForwardSound.Pitch=2.5 | |
319 | ||
320 | local emptySound=getSound(2697295) | |
321 | emptySound.Pitch=5 | |
322 | ||
323 | local glassBreakSound=getSound(144884907) | |
324 | ||
325 | local woodImpact=getSound(142082171) | |
326 | ||
327 | local fleshImpact=getSound(144884872) | |
328 | fleshImpact.Pitch=1.7 | |
329 | ||
330 | if ch:findFirstChild("Tec-99") then | |
331 | ch['Tec-99']:Destroy() | |
332 | end | |
333 | ||
334 | local tube=int("Model",ch) | |
335 | tube.Name='Tec-99' | |
336 | local hopper=Instance.new('HopperBin',plr.Backpack) | |
337 | hopper.Name=tube.Name | |
338 | Weld = function(p0,p1,x,y,z,rx,ry,rz,par)--recommend to use this with my weld. use this function only with arm lockers. | |
339 | p0.Position = p1.Position | |
340 | local w = Instance.new('Motor',par or p0) | |
341 | w.Part0 = p1 | |
342 | w.Part1 = p0 | |
343 | w.C0 = CFrame.new(x or 0,y or 0,z or 0)*CFrame.Angles(rx or 0,ry or 0,rz or 0) | |
344 | w.MaxVelocity = .1 | |
345 | return w | |
346 | end | |
347 | function clerp(c1,c2,sp) | |
348 | local R1,R2,R3 = c1:toEulerAnglesXYZ() | |
349 | local R21,R22,R23 = c2:toEulerAnglesXYZ() | |
350 | return CFrame.new( | |
351 | c1.X + (c2.X-c1.X)*sp, | |
352 | c1.Y + (c2.Y-c1.Y)*sp, | |
353 | c1.Z + (c2.Z-c1.Z)*sp)*CFrame.Angles( | |
354 | R1 + (R21-R1)*sp, | |
355 | R2 + (R22-R2)*sp, | |
356 | R3 + (R23-R3)*sp | |
357 | ) | |
358 | end | |
359 | ||
360 | tweenTable={} | |
361 | Tween = function(Weld, Stop, Step,a) | |
362 | ypcall(function() | |
363 | local func = function() | |
364 | local Start = Weld.C1 | |
365 | local X1, Y1, Z1 = Start:toEulerAnglesXYZ() | |
366 | local Stop = Stop | |
367 | local X2, Y2, Z2 = Stop:toEulerAnglesXYZ() | |
368 | if not Step then Step=0.1 end | |
369 | table.insert(tweenTable,{th=0,Weld=Weld,Step=Step,Start=Start,X1=X1,Y1=Y1,Z1=Z1,Stop=Stop,X2=X2,Y2=Y2,Z2=Z2}) | |
370 | end | |
371 | if a then coroutine.wrap(func)() else func() end | |
372 | end) | |
373 | end | |
374 | weld=function(p0,p1,c0) | |
375 | local w=Instance.new("Weld",p0) | |
376 | w.Part0=p0 | |
377 | w.Part1=p1 | |
378 | w.C0=c0 | |
379 | return w | |
380 | end | |
381 | cp=function(parent,color,size,anchored,cancollide) | |
382 | local newp=Instance.new("Part",parent) | |
383 | newp.TopSurface='SmoothNoOutlines' | |
384 | newp.BottomSurface='SmoothNoOutlines' | |
385 | newp.FrontSurface='SmoothNoOutlines' | |
386 | newp.BackSurface='SmoothNoOutlines' | |
387 | newp.RightSurface='SmoothNoOutlines' | |
388 | newp.LeftSurface='SmoothNoOutlines' | |
389 | newp.FormFactor="Custom" | |
390 | newp.BrickColor=bc(color) | |
391 | newp.Size=size | |
392 | newp.Anchored=anchored | |
393 | newp.CanCollide=cancollide | |
394 | newp:BreakJoints() | |
395 | return newp | |
396 | end | |
397 | ||
398 | initializeJoints=function() | |
399 | rabr = cp(tube,'White',Vector3.new(1,1,1),false,false) rabr.Transparency = 1 rabr.Name='Locker' | |
400 | rabr.Position = torso.Position | |
401 | rw = Weld(rabr,torso,1.5,.5,0,0,0,0) rw.Parent = tube rw.Name = 'rw' | |
402 | w = Instance.new("Weld",tube) | |
403 | w.Part0,w.Part1 = ch['Right Arm'],rabr | |
404 | w.C1 = CFrame.new(0,-.5,0) | |
405 | labr = cp(tube,'White',Vector3.new(1,1,1),false,false) labr.Transparency = 1 labr.Name='Locker' | |
406 | labr.Position = torso.Position | |
407 | lw = Weld(labr,torso,-1.5,.5,0,0,0,0) lw.Parent = tube lw.Name = 'lw' | |
408 | ww = Instance.new("Weld",tube) | |
409 | ww.Part0,ww.Part1 = ch['Left Arm'],labr | |
410 | ww.C1 = CFrame.new(0,-.5,0) | |
411 | end | |
412 | ||
413 | initializeJoints() | |
414 | ||
415 | --[[ leg locks | |
416 | rabl = cp(tube,'White',Vector3.new(1,1,1),false,false) rabl.Transparency = 1 rabl.Name='Locker' | |
417 | rabl.Position = torso.Position | |
418 | rwl = Weld(rabl,torso,0.5,-1.5,0,0,0,0) rwl.Parent = tube rwl.Name = 'rwl' | |
419 | wl = Instance.new("Weld",tube) | |
420 | wl.Part0,wl.Part1 = ch['Right Leg'],rabl | |
421 | wl.C1 = CFrame.new(0,-.5,0) | |
422 | labl = cp(tube,'White',Vector3.new(1,1,1),false,false) labl.Transparency = 1 labl.Name='Locker' | |
423 | labl.Position = torso.Position | |
424 | lwl = Weld(labl,torso,-0.5,-1.5,0,0,0,0) lwl.Parent = tube lwl.Name = 'lwl' | |
425 | wwl = Instance.new("Weld",tube) | |
426 | wwl.Part0,wwl.Part1 = ch['Left Leg'],labl | |
427 | wwl.C1 = CFrame.new(0,-.5,0) | |
428 | ]] | |
429 | --weld(ch['HumanoidRootPart'],torso,cfn()) | |
430 | ||
431 | ||
432 | local counter=Instance.new('ScreenGui',plr.PlayerGui) | |
433 | local frame=Instance.new('Frame',counter) | |
434 | frame.Size=UDim2.new(0.25,0,0.3,0) | |
435 | ||
436 | frame.Position=UDim2.new(0.1,0,0.4,0) | |
437 | frame.BackgroundTransparency=1 | |
438 | ||
439 | local ammocounter=Instance.new('TextLabel',frame) | |
440 | ammocounter.Size=UDim2.new(1,0,0.3,0) | |
441 | ammocounter.Position=UDim2.new(0,0,0.2,0) | |
442 | ammocounter.BackgroundTransparency=1 | |
443 | ammocounter.TextColor3=BrickColor.new('White').Color | |
444 | ammocounter.Font='SourceSansBold' | |
445 | ammocounter.FontSize='Size18' | |
446 | ammocounter.Text='' | |
447 | ammocounter.TextXAlignment='Left' | |
448 | ||
449 | ||
450 | local bg = Instance.new("BodyGyro",rootpart) | |
451 | bg.maxTorque = Vector3.new(math.huge,math.huge,math.huge) | |
452 | bg.P = 10000 | |
453 | bg.D = 100 | |
454 | ||
455 | ||
456 | cyl=function(prt) | |
457 | local c=int("CylinderMesh",prt) | |
458 | return c | |
459 | end | |
460 | blo=function(prt) | |
461 | local c=int("BlockMesh",prt) | |
462 | return c | |
463 | end | |
464 | ||
465 | if laser then | |
466 | aLaser=cp(tube,'Really red',Vector3.new(0.2,0.2,0.2)) | |
467 | aLaser.Transparency=1 | |
468 | cyl(aLaser).Scale=Vector3.new(0.25,1,0.25) | |
469 | aLaser.Anchored=true | |
470 | end | |
471 | ||
472 | local handle=cp(tube,primaryColor,Vector3.new(0.2,0.6,0.3)) | |
473 | blo(handle).Scale=Vector3.new(1.15,0.9,1) | |
474 | local mw=weld(ch['Right Arm'],handle,cfn(-0.4,-1,-0.19)*ang(mr(-101.5),0,0)*cfn()*ang(0,mr(-30),mr(-5))) | |
475 | ||
476 | local framepiece1=cp(tube,primaryColor,Vector3.new(0.2,0.2,0.9)) | |
477 | blo(framepiece1).Scale=Vector3.new(1.15,0.5,1) | |
478 | weld(handle,framepiece1,cfn(0,0.354,-0.3)*ang(mr(11.5),0,0)) | |
479 | ||
480 | local barrel=cp(tube,'Medium stone grey',Vector3.new(0.2,0.2,0.2)) | |
481 | cyl(barrel).Scale=Vector3.new(0.7,1.2,0.7) | |
482 | weld(framepiece1,barrel,cfn(0,0.15,-0.1)*ang(mr(-90),0,0)) | |
483 | ||
484 | local sbarrel=cp(tube,'Really black',Vector3.new(0.2,0.3,0.2)) | |
485 | cyl(sbarrel).Scale=Vector3.new(0.7,1.5,0.7) | |
486 | weld(barrel,sbarrel,cfn(0,0.35,0)) | |
487 | local hole=cp(tube,'White',Vector3.new(0.2,0.2,0.2)) | |
488 | hole.Transparency=1 | |
489 | weld(sbarrel,hole,cfn(0,0.2,0)) | |
490 | local flash=int('PointLight',hole) | |
491 | flash.Enabled=false | |
492 | flash.Range=10 | |
493 | flash.Color=BrickColor.new('Neon orange').Color | |
494 | ||
495 | ||
496 | local slide1=cp(tube,secondaryColor,Vector3.new(0.2,0.2,0.4)) | |
497 | slide1.CanCollide=false | |
498 | blo(slide1).Scale=Vector3.new(0.7,1,1.1) | |
499 | slideweld1=weld(framepiece1,slide1,cfn(0,0.15,0.23)) | |
500 | slide1.Reflectance=slideReflectance | |
501 | slide1.Material=slideMaterial | |
502 | ||
503 | local slide2=cp(tube,secondaryColor,Vector3.new(0.2,0.2,0.4)) | |
504 | slide2.CanCollide=false | |
505 | blo(slide2).Scale=Vector3.new(0.7,1,1.1) | |
506 | slideweld2=weld(slide1,slide2,cfn(0,0,-0.666)) | |
507 | slide2.Reflectance=slideReflectance | |
508 | slide2.Material=slideMaterial | |
509 | ||
510 | local slideside1=cp(tube,secondaryColor,Vector3.new(0.2,0.2,1.1)) | |
511 | slideside1.CanCollide=true | |
512 | blo(slideside1).Scale=Vector3.new(0.25,1,1) | |
513 | weld(slide1,slideside1,cfn(-0.09,0,-0.335)) | |
514 | slideside1.Reflectance=slideReflectance | |
515 | slideside1.Material=slideMaterial | |
516 | ||
517 | local slideside2=cp(tube,secondaryColor, Vector3.new(0.2,0.2,0.4)) | |
518 | slideside2.CanCollide=true | |
519 | blo(slideside2).Scale=Vector3.new(0.25,1,1.1) | |
520 | weld(slide1,slideside2,cfn(0.09,0,0)) | |
521 | slideside2.Reflectance=slideReflectance | |
522 | slideside2.Material=slideMaterial | |
523 | ||
524 | local slideside3=cp(tube,secondaryColor, Vector3.new(0.2,0.2,0.3)) | |
525 | slideside3.CanCollide=true | |
526 | blo(slideside3).Scale=Vector3.new(0.25,0.6,0.78) | |
527 | weld(slideside2,slideside3,cfn(0,-0.04,-0.335)) | |
528 | slideside3.Reflectance=slideReflectance | |
529 | slideside3.Material=slideMaterial | |
530 | ||
531 | local slideside4=cp(tube,secondaryColor, Vector3.new(0.2,0.2,0.4)) | |
532 | blo(slideside4).Scale=Vector3.new(0.25,1,1.1) | |
533 | weld(slide2,slideside4,cfn(0.09,0,0)) | |
534 | slideside4.Reflectance=slideReflectance | |
535 | slideside4.Material=slideMaterial | |
536 | ||
537 | local mgs=cp(tube,primaryColor,Vector3.new(0.2,0.2,0.2)) | |
538 | blo(mgs).Scale=Vector3.new(1.15,0.425,0.245) | |
539 | weld(handle,mgs,cfn(0,-0.3,0.125)) | |
540 | ||
541 | --[[Trigger]]-- | |
542 | local tp1=cp(tube,primaryColor,Vector3.new(0.2,0.2,0.2)) | |
543 | blo(tp1).Scale=Vector3.new(0.6,0.1,0.8) | |
544 | weld(framepiece1,tp1,cfn(0,-0.22,0.13)) | |
545 | ||
546 | local tp2=cp(tube,primaryColor,Vector3.new(0.2,0.2,0.2)) | |
547 | blo(tp2).Scale=Vector3.new(0.6,0.1,1.19) | |
548 | weld(framepiece1,tp2,cfn(0,-0.14,-0.0265)*ang(mr(45),0,0)) | |
549 | ||
550 | local trigger1=cp(tube,'Really black',Vector3.new(0.2,0.2,0.2)) | |
551 | blo(trigger1).Scale=Vector3.new(0.3,0.4,0.16) | |
552 | weld(framepiece1,trigger1,cfn(0,-0.07,0.09)) | |
553 | ||
554 | local trigger2=cp(tube,'Really black',Vector3.new(0.2,0.2,0.2)) | |
555 | blo(trigger2).Scale=Vector3.new(0.3,0.3,0.16) | |
556 | weld(trigger1,trigger2,cfn(0,-0.06,-0.015)*ang(mr(30),0,0)) | |
557 | ||
558 | ||
559 | --[[Magazine]]-- | |
560 | ||
561 | local magh=cp(tube,'Really black',Vector3.new(0.2,0.5,0.2)) | |
562 | blo(magh).Scale=Vector3.new(0.6,1,1) | |
563 | local magweld=weld(handle,magh,cfn(0,-0.025,0)) | |
564 | ||
565 | local bottom=cp(tube,'Really black',Vector3.new(0.2,0.2,0.3)) | |
566 | blo(bottom).Scale=Vector3.new(1.15,0.385,0.8) | |
567 | bottomweld=weld(magh,bottom,cfn(0,-0.28,-0.015)) | |
568 | ||
569 | if highCapMag then | |
570 | magweld:Destroy() | |
571 | magh.Size=Vector3.new(0.2,0.7,0.2) | |
572 | magweld=weld(handle,magh,cfn(0,-0.125,0)) | |
573 | bottomweld:Destroy() | |
574 | bottomweld=weld(magh,bottom,cfn(0,-0.38,-0.015)) | |
575 | magCapacity=magCapacity+23 | |
576 | magAmmo=magAmmo+23 | |
577 | end | |
578 | ||
579 | --[[Sights]]-- | |
580 | local backsight1=cp(tube,'Black',Vector3.new(0.2,0.2,0.2)) | |
581 | blo(backsight1).Scale=Vector3.new(0.3,0.3,0.3) | |
582 | weld(slide1,backsight1,cfn(0.06,0.1,0.13)) | |
583 | local backsight2=cp(tube,'Black',Vector3.new(0.2,0.2,0.2)) | |
584 | blo(backsight2).Scale=Vector3.new(0.3,0.3,0.3) | |
585 | weld(slide1,backsight2,cfn(-0.06,0.1,0.13)) | |
586 | ||
587 | local frontsight=cp(tube,'Black',Vector3.new(0.2,0.2,0.2)) | |
588 | blo(frontsight).Scale=Vector3.new(0.3,0.3,0.3) | |
589 | weld(slide1,frontsight,cfn(0,0.1,-0.85)) | |
590 | ||
591 | local dot1=cp(tube,'Lime green',Vector3.new(0.2,0.2,0.2)) | |
592 | cyl(dot1).Scale=Vector3.new(0.1,0.31,0.1) | |
593 | weld(backsight1,dot1,cfn(0,0.014,0)*ang(mr(-90),0,0)) | |
594 | ||
595 | local dot2=cp(tube,'Lime green',Vector3.new(0.2,0.2,0.2)) | |
596 | cyl(dot2).Scale=Vector3.new(0.1,0.31,0.1) | |
597 | weld(backsight2,dot2,cfn(0,0.014,0)*ang(mr(-90),0,0)) | |
598 | ||
599 | local dot3=cp(tube,'Lime green',Vector3.new(0.2,0.2,0.2)) | |
600 | cyl(dot3).Scale=Vector3.new(0.1,0.31,0.1) | |
601 | weld(frontsight,dot3,cfn(0,0.014,0)*ang(mr(-90),0,0)) | |
602 | ||
603 | local ba=cp(tube,secondaryColor,Vector3.new(0.2,0.2,0.2)) | |
604 | blo(ba).Scale=Vector3.new(1.15,0.5,1) | |
605 | weld(framepiece1,ba,cfn(0,0,-0.55)) | |
606 | ba.Reflectance=slideReflectance | |
607 | ba.Material=slideMaterial | |
608 | ||
609 | local weirdholethatpistolshave=cp(tube,'Really black', Vector3.new(0.2,0.2,0.2)) | |
610 | cyl(weirdholethatpistolshave).Scale=Vector3.new(0.4,1.01,0.4) | |
611 | weld(ba,weirdholethatpistolshave,cfn(0,0,0)*ang(mr(-90),0,0)) | |
612 | ||
613 | --[[Tactical Rails]]-- | |
614 | ||
615 | local r1=cp(tube,primaryColor,Vector3.new(0.2,0.2,0.2)) | |
616 | blo(r1).Scale=Vector3.new(1.15,0.2,0.25) | |
617 | weld(framepiece1,r1,cfn(0,-0.05,-0.17)) | |
618 | ||
619 | local r2=cp(tube,primaryColor,Vector3.new(0.2,0.2,0.2)) | |
620 | blo(r2).Scale=Vector3.new(1.15,0.2,0.25) | |
621 | weld(framepiece1,r2,cfn(0,-0.05,-0.27)) | |
622 | ||
623 | local r3=cp(tube,primaryColor,Vector3.new(0.2,0.2,0.2)) | |
624 | blo(r3).Scale=Vector3.new(1.15,0.2,0.25) | |
625 | weld(framepiece1,r3,cfn(0,-0.05,-0.37)) | |
626 | ||
627 | if laser then | |
628 | local base=cp(tube,primaryColor,Vector3.new(0.2,0.2,0.3)) | |
629 | blo(base).Scale=Vector3.new(1.15,1,1) | |
630 | weld(r2,base,cfn(0,-0.05,0)) | |
631 | basehole=cp(tube,'White',Vector3.new(0.2,0.2,0.2)) | |
632 | cyl(basehole).Scale=Vector3.new(0.4,0.4,0.4) | |
633 | weld(base,basehole,cfn(0,0,-0.13)*ang(mr(-90),0,0)) | |
634 | end | |
635 | ||
636 | if silencer then | |
637 | local sil=cp(tube,'Really black',Vector3.new(0.2,0.3,0.2)) | |
638 | fireSound.SoundId='rbxassetid://153230595' | |
639 | fireSound.Pitch=1 | |
640 | cyl(sil).Scale=Vector3.new(0.94,1.8,0.94) | |
641 | weld(hole,sil,cfn(0,0.29,0)) | |
642 | end | |
643 | ||
644 | if grip then | |
645 | local base=cp(tube,primaryColor,Vector3.new(0.2,0.2,0.3)) | |
646 | blo(base).Scale=Vector3.new(1.15,1,1) | |
647 | weld(r2,base,cfn(0,-0.05,0)) | |
648 | local hd=cp(tube,primaryColor,Vector3.new(0.2,0.6,0.2)) | |
649 | cyl(hd) | |
650 | weld(base,hd,cfn(0,-0.3,0)) | |
651 | crosshairSpread=3 | |
652 | spreadint=spreadint-0.3 | |
653 | end | |
654 | ||
655 | --[[Test Functions]]-- | |
656 | ||
657 | local debounce=false | |
658 | local out=false | |
659 | local bs=false | |
660 | cockSlide=function() -- hahaha yes i know | |
661 | slideBackSound:Play() | |
662 | if magAmmo<1 and out==true and bs==false then | |
663 | wait() | |
664 | slideweld1.C0=slideweld1.C0*cfn(0,0,0.22) | |
665 | else | |
666 | for i=1,2 do | |
667 | wait() | |
668 | slideweld1.C0=slideweld1.C0*cfn(0,0,0.22) | |
669 | end | |
670 | end | |
671 | local ajar=false | |
672 | if magAmmo==1 then | |
673 | ajar=true | |
674 | end | |
675 | if magAmmo>0 then | |
676 | createShell() | |
677 | --magAmmo=magAmmo-1 | |
678 | ammocounter.Text='' | |
679 | for i=1,magAmmo do | |
680 | ammocounter.Text=ammocounter.Text .. 'I' | |
681 | end | |
682 | end | |
683 | wait(0.15) | |
684 | slideForwardSound:Play() | |
685 | for i=1,2 do | |
686 | wait() | |
687 | slideweld1.C0=slideweld1.C0*cfn(0,0,-0.22) | |
688 | end | |
689 | if ajar==true then | |
690 | out=true | |
691 | slideweld1.C0=cfn(0,0.15,0.23) | |
692 | slideweld1.C0=slideweld1.C0*cfn(0,0,0.22) | |
693 | end | |
694 | end | |
695 | ||
696 | --fx | |
697 | local firefx=cp(tube,'Neon orange',Vector3.new(0.7,1.1,0.7)) | |
698 | firefx.Transparency=1 | |
699 | local mesh=Instance.new('SpecialMesh',firefx) | |
700 | mesh.MeshType='Sphere' | |
701 | firefx.Material='Neon' | |
702 | weld(hole,firefx,cfn(0,1,0)) | |
703 | ||
704 | local smokefx=Instance.new('Smoke',hole) | |
705 | smokefx.Enabled=false | |
706 | barrel.CanCollide=true | |
707 | ||
708 | ||
709 | ||
710 | ||
711 | local oc = oc or function(...) return ... end | |
712 | ||
713 | function ragJoint(hit,r,d) | |
714 | Spawn(oc(function() | |
715 | d = d or 0 | |
716 | local rpar,r0,r1 = r.Parent,r.Part0,r.Part1 | |
717 | if d > 0 then wait(d) end | |
718 | local p = hit:Clone() | |
719 | p:BreakJoints() | |
720 | p:ClearAllChildren() | |
721 | p.FormFactor = "Custom" | |
722 | p.Size = p.Size/2 | |
723 | p.Transparency = 1 | |
724 | p.CanCollide = true | |
725 | p.Name = "Colliduh" | |
726 | p.Parent = hit | |
727 | local w = Instance.new("Weld",p) | |
728 | w.Part0 = hit | |
729 | w.Part1 = p | |
730 | w.C0 = CFrame.new(0,-p.Size.Y/2,0) | |
731 | local rot = Instance.new("Rotate",rpar) | |
732 | rot.Name = r.Name | |
733 | rot.Part0 = r0 | |
734 | rot.Part1 = r1 | |
735 | rot.C0 = r.C0 | |
736 | rot.C1 = r.C1 | |
737 | r0.Velocity = Vector3.new() | |
738 | r1.Velocity = Vector3.new() | |
739 | r:Destroy() | |
740 | end)) | |
741 | end | |
742 | ||
743 | ||
744 | createShell=function() | |
745 | local shell=cp(tube,'Deep orange',Vector3.new(0.2,0.3,0.2)) | |
746 | shell.CanCollide=true | |
747 | shell.Reflectance=0.3 | |
748 | cyl(shell) | |
749 | shell.CFrame=barrel.CFrame*ang(mr(-90),0,0) | |
750 | magAmmo=magAmmo-1 | |
751 | ammocounter.Text='' | |
752 | for i=1,magAmmo do | |
753 | ammocounter.Text=ammocounter.Text .. 'I' | |
754 | end | |
755 | game.Debris:AddItem(shell,3) | |
756 | end | |
757 | ||
758 | reloadPistol=function() | |
759 | local current=magAmmo | |
760 | Tween(lw,cfn()) | |
761 | Tween(rw,cfn()*ang(mr(-102),0,0)) | |
762 | wait(0.4) | |
763 | releaseSound:Play() | |
764 | bottom.Transparency=1 | |
765 | magh.Transparency=1 | |
766 | local mag1=magh:clone() | |
767 | mag1.Transparency=0 | |
768 | mag1.Weld:Destroy'' | |
769 | local mag2=bottom:clone() | |
770 | mag2.Transparency=0 | |
771 | mag1:BreakJoints'' | |
772 | mag2:BreakJoints'' | |
773 | local bm1=mag1:clone() | |
774 | local bm2=mag2:clone() | |
775 | mag1.Parent=tube | |
776 | mag2.Parent=tube | |
777 | mag1.CFrame=magh.CFrame | |
778 | weld(mag1,mag2,cfn(0,-0.28,-0.015)) | |
779 | magAmmo=0 | |
780 | ammocounter.Text='' | |
781 | for i=1,magAmmo do | |
782 | ammocounter.Text=ammocounter.Text .. 'I' | |
783 | end | |
784 | wait() | |
785 | mag1.CanCollide=true | |
786 | mag2.CanCollide=true | |
787 | game.Debris:AddItem(mag1,2) | |
788 | game.Debris:AddItem(mag2,2) | |
789 | wait(0.1) | |
790 | Tween(lw,cfn()*ang(mr(25),0,0)) | |
791 | bm1.Parent=tube | |
792 | bm2.Parent=tube | |
793 | weld(bm1,bm2,cfn(0,-0.28,-0.015)) | |
794 | local fa=weld(ch['Left Arm'],bm1,cfn(0,-1.1,0)*ang(mr(-90),0,0)) | |
795 | wait(0.1) | |
796 | Tween(lw,cfn(0,1.4,0)*ang(mr(-109),mr(60),mr(10)),0.07) | |
797 | wait(0.25) | |
798 | magazinelockSound:Play() | |
799 | wait() | |
800 | -- reloadSound:Play() | |
801 | fa:Destroy'' | |
802 | bm1:Destroy'' | |
803 | bm2:Destroy'' | |
804 | bottom.Transparency=0 | |
805 | magh.Transparency=0 | |
806 | local totalcap=0 | |
807 | if current<1 then --none in chamber reload | |
808 | --slideweld1.C0=cfn(0,0,0.45) | |
809 | Tween(rw,cfn(0,0.7,0)*ang(mr(-90),mr(-30),0)) | |
810 | Tween(lw,cfn(0,0.7,0)*ang(mr(-115),mr(35),0)) | |
811 | wait(0.1) | |
812 | spawn(function() | |
813 | cockSlide() | |
814 | end) | |
815 | Tween(lw,cfn(0,0.7,0)*ang(mr(-115),mr(55),0)) | |
816 | wait(0.3) | |
817 | totalcap=magCapacity | |
818 | else | |
819 | totalcap=magCapacity+1 | |
820 | end | |
821 | magAmmo=totalcap | |
822 | out=false | |
823 | ammocounter.Text='' | |
824 | for i=1,magAmmo do | |
825 | ammocounter.Text=ammocounter.Text .. 'I' | |
826 | end | |
827 | restorePosition() | |
828 | end | |
829 | ||
830 | firePistol=function() | |
831 | switchIco(currentIco+crosshairSpread) | |
832 | if not jammed and not out then | |
833 | spread=spread+spreadint | |
834 | end | |
835 | print(spread) | |
836 | fireSound.Pitch=math.random(math.random(fireSound.Pitch-0.2,fireSound.Pitch-0.1),math.random(fireSound.Pitch,fireSound.Pitch+0.1)) | |
837 | if magAmmo>0 and jammed==false then | |
838 | local ajar=false | |
839 | if magAmmo==1 then | |
840 | ajar=true | |
841 | end | |
842 | user=ch | |
843 | local ray = Ray.new(hole.CFrame.p, ((m.Hit.p+Vector3.new(math.random(-spread,spread)/6.35,math.random(-spread,spread)/6.35,math.random(-spread,spread)/6.35) )- hole.CFrame.p).unit*300) | |
844 | local hit, position = game.Workspace:FindPartOnRay(ray, user) | |
845 | if hit then | |
846 | if hit.Transparency>0.285 and hit:GetMass()<3000 and hit.Parent.className~='Hat' then | |
847 | local temps=glassBreakSound:clone() | |
848 | temps.Parent=hit | |
849 | temps.Pitch=math.random(math.random(temps.Pitch-0.2,temps.Pitch-0.1),math.random(temps.Pitch,temps.Pitch+0.1)) | |
850 | temps:Play'' | |
851 | start_fragmentation(position,.25) | |
852 | end | |
853 | if tostring(hit.Material)=='Enum.Material.Wood' and hit.Transparency<0.05 then | |
854 | local temps=woodImpact:clone() | |
855 | temps.Volume=1 | |
856 | temps.Pitch=math.random(math.random(temps.Pitch-0.2,temps.Pitch-0.1),math.random(temps.Pitch,temps.Pitch+0.1)) | |
857 | temps.Parent=hit | |
858 | temps:Play'' | |
859 | start_fragmentation(position,.15) | |
860 | end | |
861 | ypcall(function() | |
862 | if hit and hit.Parent and hit.Parent:findFirstChild'Humanoid' then | |
863 | local temps=fleshImpact:clone() | |
864 | temps.Parent=hit | |
865 | temps:Play() | |
866 | if hit.Name~='Head' then | |
867 | if pAmmunition==true then | |
868 | hit.Parent.Humanoid:TakeDamage(math.random(30,65)) | |
869 | else | |
870 | hit.Parent.Humanoid:TakeDamage(math.random(10,24)) | |
871 | end | |
872 | local guy=hit.Parent | |
873 | if guy.Name~='TheDarkRevenant' then | |
874 | for i,v in pairs(guy:GetChildren()) do | |
875 | if v.className=='Hat' then | |
876 | v.Handle:BreakJoints() | |
877 | end | |
878 | local r = guy.Torso:FindFirstChild(v.Name:gsub("Arm","Shoulder"):gsub("Leg","Hip")) | |
879 | if v:IsA("BasePart") and r then | |
880 | ragJoint(v,r,.1) | |
881 | elseif v:IsA("Humanoid") then | |
882 | spawn(function() | |
883 | wait(0.5) | |
884 | v.PlatformStand = true | |
885 | v.Changed:connect(function() | |
886 | v.PlatformStand = true | |
887 | end) | |
888 | end) | |
889 | end | |
890 | end | |
891 | end | |
892 | ||
893 | else | |
894 | if hit.Parent.Name~='TheDarkRevenant' then | |
895 | hit.Parent:BreakJoints() | |
896 | end | |
897 | end | |
898 | end | |
899 | ||
900 | if hit.Parent.className=='Hat' then | |
901 | hit.CanCollide=true | |
902 | hit:BreakJoints() | |
903 | hit.Velocity=m.Hit.p*5 | |
904 | end | |
905 | end) | |
906 | end | |
907 | if m.Target then | |
908 | local p = Instance.new("Part") | |
909 | p.formFactor = "Custom" | |
910 | p.Size = Vector3.new(0.5,0.5,0.5) | |
911 | p.Transparency = 1 | |
912 | p.CanCollide = false | |
913 | p.Locked = true | |
914 | p.CFrame = CFrame.new(position.x,position.y,position.z)--mouse.Target.CFrame+(mouse.Hit.p-mouse.Target.Position) | |
915 | local w = Instance.new("Weld") | |
916 | w.Part0 = mouse.Target | |
917 | w.Part1 = p | |
918 | w.C0 = mouse.Target.CFrame:inverse() | |
919 | w.C1 = p.CFrame:inverse() | |
920 | w.Parent = p | |
921 | local d = Instance.new("Decal") | |
922 | d.Parent = p | |
923 | d.Face = mouse.TargetSurface | |
924 | d.Texture = 'rbxassetid://' .. tostring(bulletholes[math.random(#bulletholes)]-2) | |
925 | p.Parent = tube | |
926 | game.Debris:AddItem(p,6) | |
927 | end | |
928 | if recoil==true then | |
929 | cam:SetRoll(math.random(-2,2)) | |
930 | cam:TiltUnits(0.501) | |
931 | end | |
932 | local th=cp(tube,"Really black",Vector3.new(1,1,1)) | |
933 | th.CanCollide=false | |
934 | th.Anchored=true | |
935 | th.CFrame=CFrame.new(position.x,position.y,position.z) | |
936 | local spm=Instance.new('SpecialMesh',th) | |
937 | spm.MeshType='Sphere' | |
938 | spm.Scale=Vector3.new(0.05,0.05,0.05) | |
939 | spawn(function() | |
940 | for i=1,5 do | |
941 | wait() | |
942 | spm.Scale=spm.Scale+Vector3.new(0.16,0.16,0.16) | |
943 | th.Transparency=th.Transparency+0.2 | |
944 | end | |
945 | th:Destroy() | |
946 | end) | |
947 | fireSound:Play() | |
948 | spawn(function() | |
949 | firefx.Transparency=0 | |
950 | wait() | |
951 | firefx.Transparency=1 | |
952 | end) | |
953 | spawn(function() | |
954 | flash.Enabled=true | |
955 | for i=1,2 do | |
956 | wait() | |
957 | slideweld1.C0=slideweld1.C0*cfn(0,0,0.22) | |
958 | end | |
959 | flash.Enabled=false | |
960 | createShell() | |
961 | for i=1,2 do | |
962 | wait() | |
963 | slideweld1.C0=slideweld1.C0*cfn(0,0,-0.22) | |
964 | end | |
965 | slideweld1.C0=cfn(0,0.15,0.23) | |
966 | if ajar==true then | |
967 | out=true | |
968 | slideweld1.C0=cfn(0,0.15,0.23) | |
969 | slideweld1.C0=slideweld1.C0*cfn(0,0,0.22) | |
970 | end | |
971 | end) | |
972 | ammocounter.Text='' | |
973 | for i=1,magAmmo do | |
974 | ammocounter.Text=ammocounter.Text .. 'I' | |
975 | end | |
976 | wait() | |
977 | Tween(rw,cfn(0,0.7,0)*ang(mr(-100),mr(-30),0),0.62) | |
978 | if not grip then | |
979 | Tween(lw,cfn(0,0.7,0)*ang(mr(-100),mr(30),0),0.62) | |
980 | else | |
981 | Tween(lw,cfn(0,1.3,0)*ang(mr(-100),mr(30),0),0.62) | |
982 | end | |
983 | wait(0.065) | |
984 | restorePosition(0.3) | |
985 | else | |
986 | if magAmmo<1 then | |
987 | slideweld1.C0=cfn(0,0.15,0.23) | |
988 | slideweld1.C0=slideweld1.C0*cfn(0,0,0.22) | |
989 | end | |
990 | emptySound:Play() | |
991 | end | |
992 | if math.random(jamRate)==jamRate and magAmmo>0 then | |
993 | jammed=true | |
994 | end | |
995 | end | |
996 | ||
997 | debounced=function() | |
998 | if sheathed==false and debounce==false then | |
999 | return true | |
1000 | end | |
1001 | end | |
1002 | ||
1003 | mouse.Button1Down:connect(function() | |
1004 | if debounced() then | |
1005 | if automatic==false then | |
1006 | debounce=true | |
1007 | firePistol() | |
1008 | debounce=false | |
1009 | else | |
1010 | heldDown=true | |
1011 | firePistol() | |
1012 | end | |
1013 | end | |
1014 | end) | |
1015 | ||
1016 | mouse.Button1Up:connect(function() | |
1017 | heldDown=false | |
1018 | end) | |
1019 | ||
1020 | sheathGun=function() | |
1021 | ammocounter.Visible=false | |
1022 | if laser then | |
1023 | laserEnabled=false | |
1024 | aLaser.Transparency=1 | |
1025 | end | |
1026 | Tween(rw,cfn()) | |
1027 | Tween(lw,cfn()) | |
1028 | wait(0.1) | |
1029 | mw:Destroy'' | |
1030 | mw=nil | |
1031 | mw=weld(tor,handle,cfn(1.11,-1.09,0)*ang(mr(-111.5),0,0)) | |
1032 | labr:Destroy() | |
1033 | rabr:Destroy() | |
1034 | bg.maxTorque=Vector3.new() | |
1035 | sheathed=true | |
1036 | end | |
1037 | ||
1038 | unsheathGun=function() | |
1039 | ammocounter.Visible=true | |
1040 | mw:Destroy'' | |
1041 | mw=nil | |
1042 | initializeJoints() | |
1043 | mw=weld(ch['Right Arm'],handle,cfn(-0.4,-1,-0.19)*ang(mr(-101.5),0,0)*cfn()*ang(0,mr(-30),mr(-5))) | |
1044 | restorePosition() | |
1045 | bg.maxTorque = Vector3.new(math.huge,math.huge,math.huge) | |
1046 | sheathed=false | |
1047 | end | |
1048 | ||
1049 | laserEnabled=false | |
1050 | ||
1051 | mouse.KeyDown:connect(function(key) | |
1052 | if key=='r' and debounced() then | |
1053 | debounce=true | |
1054 | reloadPistol() | |
1055 | debounce=false | |
1056 | elseif key=='f' and debounced() then | |
1057 | debounce=true | |
1058 | bs=true | |
1059 | Tween(rw,cfn(0,0.7,0)*ang(mr(-90),mr(-30),0)) | |
1060 | Tween(lw,cfn(0,0.7,0)*ang(mr(-115),mr(35),0)) | |
1061 | wait(0.1) | |
1062 | spawn(function() | |
1063 | cockSlide() | |
1064 | end) | |
1065 | Tween(lw,cfn(0,0.7,0)*ang(mr(-115),mr(55),0)) | |
1066 | wait(0.3) | |
1067 | jammed=false | |
1068 | restorePosition() | |
1069 | bs=false | |
1070 | debounce=false | |
1071 | elseif key=='l' and debounced() then | |
1072 | if not laserEnabled then | |
1073 | laserEnabled=true | |
1074 | aLaser.Transparency=0.35 | |
1075 | else | |
1076 | laserEnabled=false | |
1077 | aLaser.Transparency=1 | |
1078 | end | |
1079 | end | |
1080 | end) | |
1081 | ||
1082 | restorePosition=function(speed) | |
1083 | if not grip then | |
1084 | Tween(rw,cfn(0,0.7,0)*ang(mr(-90),mr(-30),0),speed) | |
1085 | Tween(lw,cfn(0,0.7,0)*ang(mr(-90),mr(30),0),speed) | |
1086 | else | |
1087 | Tween(rw,cfn(0,0.7,0)*ang(mr(-90),mr(-30),0),speed) | |
1088 | Tween(lw,cfn(0,1.3,0)*ang(mr(-90),mr(30),0),speed) | |
1089 | end | |
1090 | end | |
1091 | ||
1092 | hopper.Selected:connect(function() | |
1093 | unsheathGun() | |
1094 | end) | |
1095 | ||
1096 | hopper.Deselected:connect(function() | |
1097 | sheathGun() | |
1098 | end) | |
1099 | ||
1100 | game:service'RunService'.RenderStepped:connect(function() | |
1101 | bg.cframe = CFrame.new(rootpart.Position,mouse.Hit.p*Vector3.new(1,0,1)+rootpart.Position*Vector3.new(0,1,0)) | |
1102 | if laserEnabled==true then | |
1103 | local user=ch | |
1104 | local ray = Ray.new(hole.CFrame.p, (m.Hit.p - hole.CFrame.p).unit*300) | |
1105 | local hit, position = game.Workspace:FindPartOnRay(ray, user) | |
1106 | local distance = (position - basehole.CFrame.p).magnitude | |
1107 | aLaser.Size=Vector3.new(0.2,distance,0.2) | |
1108 | aLaser.CFrame=CFrame.new(position, basehole.CFrame.p) * CFrame.new(0, 0, -distance/2) * ang(mr(-90),0,0) | |
1109 | end | |
1110 | for _,v in pairs(tweenTable) do | |
1111 | if v.Weld.C1==v.Stop then | |
1112 | table.remove(tweenTable,_) | |
1113 | else | |
1114 | if v.th<0.9 then | |
1115 | v.th=v.th+v.Step | |
1116 | i=v.th | |
1117 | v.Weld.C1 = CFrame.new( (v.Start.p.X * (1 - i)) + (v.Stop.p.X * i), | |
1118 | (v.Start.p.Y * (1 - i)) + (v.Stop.p.Y * i), | |
1119 | (v.Start.p.Z * (1 - i)) + (v.Stop.p.Z * i)) * CFrame.fromEulerAnglesXYZ( | |
1120 | (v.X1 * (1 - i)) + (v.X2 * i), (v.Y1 * (1 - i)) + (v.Y2 * i), | |
1121 | (v.Z1 * (1 - i)) + (v.Z2 * i) ) | |
1122 | else | |
1123 | v.Weld.C1 = v.Stop | |
1124 | end | |
1125 | end | |
1126 | end | |
1127 | end) | |
1128 | for i=1,magAmmo do | |
1129 | ammocounter.Text=ammocounter.Text .. 'I' | |
1130 | end | |
1131 | ||
1132 | sheathGun() | |
1133 | ||
1134 | spawn(function() | |
1135 | while wait(0.07) do | |
1136 | if heldDown==true then | |
1137 | spawn(function() | |
1138 | firePistol() | |
1139 | end) | |
1140 | end | |
1141 | end | |
1142 | end) | |
1143 | m.TargetFilter=tube | |
1144 | ||
1145 | while wait(0.03) do | |
1146 | if spread>1 then | |
1147 | spread=spread-spreadint/4 | |
1148 | end | |
1149 | if spread<1 then | |
1150 | spread=1 | |
1151 | end | |
1152 | if currentIco>2 then | |
1153 | switchIco(currentIco-1) | |
1154 | end | |
1155 | end | |
1156 | ||
1157 | --hl/https://httpget-inumeration.c9.io/mp45.lua | |
1158 | --local/game.Players.Conmiro:Destroy'' |