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