SHOW:
|
|
- or go back to the newest paste.
1 | - | ---creationed by IwasVivedVenom2 |
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,game,owner = owner,game | |
4 | local RealPlayer = Player | |
5 | do print("FE Compatibility code V2 by Mokiros")local RealPlayer=RealPlayer;script.Parent=RealPlayer.Character;local a=function(b)b[1].f[b[2]]=nil end;local c={__index={disconnect=a,Disconnect=a}}local d={__index={Connect=function(b,e)local f=tostring(math.random(0,10000))while b.f[f]do f=tostring(math.random(0,10000))end;b.f[f]=e;return setmetatable({b,f},c)end}}d.__index.connect=d.__index.Connect;local function g()return setmetatable({f={}},d)end;local h={Hit=CFrame.new(),KeyUp=g(),KeyDown=g(),Button1Up=g(),Button1Down=g(),Button2Up=g(),Button2Down=g()}h.keyUp=h.KeyUp;h.keyDown=h.KeyDown;local i={InputBegan=g(),InputEnded=g()}local CAS={Actions={},BindAction=function(self,j,k,l,...)CAS.Actions[j]=k and{Name=j,Function=k,Keys={...}}or nil end}CAS.UnbindAction=CAS.BindAction;local function m(self,n,...)for o,e in pairs(self[n].f)do e(...)end end;h.T=m;i.T=m;local p=Instance.new("RemoteEvent")p.Name="UserInput_Event"p.OnServerEvent:Connect(function(q,r)if q~=RealPlayer then return end;h.Target=r.e;h.Hit=r.d;if not r.f then local s=r.c==Enum.UserInputState.Begin;if r.b==Enum.UserInputType.MouseButton1 then return h:T(s and"Button1Down"or"Button1Up")end;if r.b==Enum.UserInputType.MouseButton2 then return h:T(s and"Button2Down"or"Button2Up")end;for o,t in pairs(CAS.Actions)do for o,u in pairs(t.Keys)do if u==r.a then t.Function(t.Name,r.c,r)end end end;h:T(s and"KeyDown"or"KeyUp",r.a.Name:lower())i:T(s and"InputBegan"or"InputEnded",r,false)end end)p.Parent=NLS([==[local a=script:WaitForChild("UserInput_Event")local b=owner:GetMouse()local c=game:GetService("UserInputService")local d=function(e,f)if f then return end;a:FireServer({a=e.KeyCode,b=e.UserInputType,c=e.UserInputState,d=b.Hit,e=b.Target})end;c.InputBegan:Connect(d)c.InputEnded:Connect(d)local g,h;local i=game:GetService("RunService").Heartbeat;while true do if g~=b.Hit or h~=b.Target then g,h=b.Hit,b.Target;a:FireServer({f=1,Target=h,d=g})end;for j=1,2 do i:Wait()end end]==],script)local v=game;local w={__index=function(self,u)local x=rawget(self,"_RealService")if x then return typeof(x[u])=="function"and function(o,...)return x[u](x,...)end or x[u]end end,__newindex=function(self,u,y)local x=rawget(self,"_RealService")if x then x[u]=y end end}local function z(t,A)t._RealService=typeof(A)=="string"and v:GetService(A)or A;return setmetatable(t,w)end;local B={GetService=function(self,x)return rawget(self,x)or v:GetService(x)end,Players=z({LocalPlayer=z({GetMouse=function(self)return h end},Player)},"Players"),UserInputService=z(i,"UserInputService"),ContextActionService=z(CAS,"ContextActionService"),RunService=z({_btrs={},RenderStepped=v:GetService("RunService").Heartbeat,BindToRenderStep=function(self,j,o,k)self._btrs[j]=self.Heartbeat:Connect(k)end,UnbindFromRenderStep=function(self,j)self._btrs[j]:Disconnect()end},"RunService")}rawset(B.Players,"localPlayer",B.Players.LocalPlayer)B.service=B.GetService;z(B,game)game,owner=B,B.Players.LocalPlayer end ---creationed by IwasVivedVenom2 | |
6 | --Converted with ttyyuu12345's model to script plugin v4 | |
7 | function sandbox(var,func) | |
8 | local env = getfenv(func) | |
9 | local newenv = setmetatable({},{ | |
10 | __index = function(self,k) | |
11 | if k=="script" then | |
12 | return var | |
13 | else | |
14 | return env[k] | |
15 | end | |
16 | end, | |
17 | }) | |
18 | setfenv(func,newenv) | |
19 | return func | |
20 | end | |
21 | cors = {} | |
22 | mas = Instance.new("Model",game:GetService("Lighting")) | |
23 | Tool0 = Instance.new("Tool") | |
24 | LocalScript1 = Instance.new("LocalScript") | |
25 | Vector3Value2 = Instance.new("Vector3Value") | |
26 | IntValue3 = Instance.new("IntValue") | |
27 | BoolValue4 = Instance.new("BoolValue") | |
28 | IntValue5 = Instance.new("IntValue") | |
29 | BoolValue6 = Instance.new("BoolValue") | |
30 | Animation7 = Instance.new("Animation") | |
31 | BoolValue8 = Instance.new("BoolValue") | |
32 | ScreenGui9 = Instance.new("ScreenGui") | |
33 | Frame10 = Instance.new("Frame") | |
34 | Frame11 = Instance.new("Frame") | |
35 | Frame12 = Instance.new("Frame") | |
36 | ImageLabel13 = Instance.new("ImageLabel") | |
37 | ImageLabel14 = Instance.new("ImageLabel") | |
38 | Frame15 = Instance.new("Frame") | |
39 | ImageLabel16 = Instance.new("ImageLabel") | |
40 | ImageLabel17 = Instance.new("ImageLabel") | |
41 | ImageLabel18 = Instance.new("ImageLabel") | |
42 | Frame19 = Instance.new("Frame") | |
43 | Frame20 = Instance.new("Frame") | |
44 | ImageLabel21 = Instance.new("ImageLabel") | |
45 | ImageLabel22 = Instance.new("ImageLabel") | |
46 | Frame23 = Instance.new("Frame") | |
47 | ImageLabel24 = Instance.new("ImageLabel") | |
48 | ImageLabel25 = Instance.new("ImageLabel") | |
49 | Animation26 = Instance.new("Animation") | |
50 | Animation27 = Instance.new("Animation") | |
51 | SpecialMesh28 = Instance.new("SpecialMesh") | |
52 | Script29 = Instance.new("Script") | |
53 | Script30 = Instance.new("Script") | |
54 | Script31 = Instance.new("Script") | |
55 | Script32 = Instance.new("Script") | |
56 | Script33 = Instance.new("Script") | |
57 | Script34 = Instance.new("Script") | |
58 | LocalScript35 = Instance.new("LocalScript") | |
59 | LocalScript36 = Instance.new("LocalScript") | |
60 | Part37 = Instance.new("Part") | |
61 | Sound38 = Instance.new("Sound") | |
62 | Sound39 = Instance.new("Sound") | |
63 | SpecialMesh40 = Instance.new("SpecialMesh") | |
64 | Tool0.Name = "Trenchgun" | |
65 | Tool0.Parent = mas | |
66 | Tool0.TextureId = "rbxassetid://94252022" | |
67 | Tool0.GripForward = Vector3.new(-0.500696421, -0.104253426, -0.859321952) | |
68 | Tool0.GripPos = Vector3.new(0.0644919276, -0.358220965, 0.191235617) | |
69 | Tool0.GripRight = Vector3.new(0.865328908, -0.0344124958, -0.500021636) | |
70 | Tool0.GripUp = Vector3.new(-0.0225575566, 0.993955255, -0.107443735) | |
71 | LocalScript1.Parent = Tool0 | |
72 | table.insert(cors,sandbox(LocalScript1,function() | |
73 | -- Made by Stickmasterluke | |
74 | -- edited by fusroblox | |
75 | ||
76 | function WaitForChild(obj, name) | |
77 | while not obj:FindFirstChild(name) do | |
78 | wait() | |
79 | print("1waiting for " .. name) | |
80 | end | |
81 | return obj:FindFirstChild(name) | |
82 | end | |
83 | ||
84 | local function FindCharacterAncestor(subject) | |
85 | if subject and subject ~= Workspace then | |
86 | if subject:FindFirstChild('Humanoid') then | |
87 | return subject | |
88 | else | |
89 | return FindCharacterAncestor(subject.Parent) | |
90 | end | |
91 | end | |
92 | return nil | |
93 | end | |
94 | ||
95 | local Tool = script.Parent | |
96 | ||
97 | local GunObj ={ | |
98 | Reloading = "http://www.roblox.com/asset/?id=94155503", | |
99 | ||
100 | Cursors = { | |
101 | "http://www.roblox.com/asset/?id=94154683", -- black | |
102 | "http://www.roblox.com/asset/?id= 94154829", -- red | |
103 | "http://www.roblox.com/asset/?id=94155503", | |
104 | "http://www.roblox.com/asset/?id=94155569" | |
105 | }, | |
106 | ||
107 | ClipSize = 30, | |
108 | Equipped = false, | |
109 | ||
110 | Player = game.Players.localPlayer, | |
111 | Ammo = WaitForChild(script.Parent,"Ammo"), | |
112 | Clips, | |
113 | Gui = WaitForChild(Tool,"AmmoHud"), | |
114 | NumberImages={}, | |
115 | IdleAni, | |
116 | MyMouse | |
117 | ||
118 | } | |
119 | ||
120 | local ChestWeld | |
121 | Tool.Equipped:connect(function(mouse) GunObj:OnEquipped(mouse) end) | |
122 | local initialized=false | |
123 | ||
124 | function GunObj:Initialize() | |
125 | if initialized then return end | |
126 | initialized=true | |
127 | self.Ammo.Changed:connect(function()self:UpdateGui()end) | |
128 | ||
129 | WaitForChild(Tool, "Reloading") | |
130 | print('got to connections!!!!! ') | |
131 | Tool.Reloading.Changed:connect(function() self:UpdateGui() end) | |
132 | Tool.Unequipped:connect(function() self:OnUnequipped() end) | |
133 | ||
134 | Tool.DoFireAni.Changed:connect(PlayFireAni) | |
135 | self.NumberImages['0']=94128401 | |
136 | self.NumberImages['1']=94128421 | |
137 | self.NumberImages['2']=94128434 | |
138 | self.NumberImages['3']=94128446 | |
139 | self.NumberImages['4']=94128466 | |
140 | self.NumberImages['5']=94128485 | |
141 | self.NumberImages['6']=94128496 | |
142 | self.NumberImages['7']=94128523 | |
143 | self.NumberImages['8']=94128538 | |
144 | self.NumberImages['9']=94128538 | |
145 | ||
146 | local bar=WaitForChild(self.Gui,'Bar') | |
147 | self:UpdateNumbers(self.ClipSize..'', WaitForChild(bar,'TotalAmmo')) | |
148 | end | |
149 | ||
150 | function GunObj:UpdateNumbers(data,frame) | |
151 | if string.len(data)==0 then | |
152 | data= '0'..data | |
153 | end | |
154 | if string.len(data)==1 then | |
155 | data= '0'..data | |
156 | end | |
157 | ||
158 | local digit=WaitForChild(WaitForChild(frame,'1'),'digit') | |
159 | if digit.Image ~='http://www.roblox.com/asset/?id='..self.NumberImages[string.sub(data,1,1)] then | |
160 | local ndigit=digit:Clone() | |
161 | ndigit.Position=UDim2.new(ndigit.Position.X.Scale,ndigit.Position.X.Offset,ndigit.Position.Y.Scale,ndigit.Position.Y.Offset-65) | |
162 | ndigit.Image='http://www.roblox.com/asset/?id='..self.NumberImages[string.sub(data,1,1)] | |
163 | ndigit.Parent=digit.Parent | |
164 | ndigit:TweenPosition(digit.Position, "Out", "Quad", .1,true) | |
165 | digit.Name='oldDigit' | |
166 | digit:TweenPosition(UDim2.new(digit.Position.X.Scale,digit.Position.X.Offset,digit.Position.Y.Scale, | |
167 | digit.Parent.Position.Y.Offset+95), "Out", "Quad", .25,true) | |
168 | game.Debris:AddItem(digit,1) | |
169 | end | |
170 | digit=WaitForChild(WaitForChild(frame,'2'),'digit') | |
171 | if digit.Image ~='http://www.roblox.com/asset/?id='..self.NumberImages[string.sub(data,2,2)] then | |
172 | ndigit=digit:Clone() | |
173 | ndigit.Position=UDim2.new(ndigit.Position.X.Scale,ndigit.Position.X.Offset,ndigit.Position.Y.Scale,ndigit.Position.Y.Offset-65) | |
174 | ndigit.Image='http://www.roblox.com/asset/?id='..self.NumberImages[string.sub(data,2,2)] | |
175 | ndigit.Parent=digit.Parent | |
176 | ndigit:TweenPosition(UDim2.new(digit.Position.X.Scale,digit.Position.X.Offset,digit.Position.Y.Scale,0), "Out", "Quad", .25,true) | |
177 | digit.Name='oldDigit' | |
178 | digit:TweenPosition(UDim2.new(digit.Position.X.Scale,digit.Position.X.Offset,digit.Position.Y.Scale, | |
179 | digit.Parent.Position.Y.Offset+95), "Out", "Quad", .25,true) | |
180 | game.Debris:AddItem(digit,1) | |
181 | end | |
182 | end | |
183 | ||
184 | function GunObj:UpdateGui() | |
185 | if self.Equipped then | |
186 | local Player = game.Players.localPlayer | |
187 | if Player ~= nil then | |
188 | if self.Ammo == nil then | |
189 | --self.Gui.Bar.GunLabel.Text ="Futuro Heavy Pistol" | |
190 | --self.Gui.Bar.AmmoLabel.Text = "" | |
191 | else | |
192 | --self.Gui.Bar.GunLabel.Text ="Futuro Heavy Pistol" | |
193 | --self.Gui.Bar.AmmoLabel.Text = tostring(self.Ammo.Value).."/"..tostring(self.ClipSize) | |
194 | self:UpdateNumbers(tostring(self.Ammo.Value),WaitForChild(self.Gui.Bar,'AmmoLeft')) | |
195 | end | |
196 | if Tool.Reloading.Value then | |
197 | --self.Gui.Bar.AmmoLabel.Text = "Reloading" | |
198 | end | |
199 | end | |
200 | end | |
201 | end | |
202 | ||
203 | function GunObj:CursorUpdate(mouse) | |
204 | local reloadCounter=0 | |
205 | while self.Equipped do | |
206 | if Tool.Reloading.Value then | |
207 | reloadCounter=reloadCounter+1 | |
208 | if reloadCounter%20<10 then | |
209 | mouse.Icon = self.Cursors[3] | |
210 | else | |
211 | mouse.Icon = self.Cursors[4] | |
212 | end | |
213 | elseif mouse.Target and FindCharacterAncestor(mouse.Target) then | |
214 | mouse.Icon = self.Cursors[2] | |
215 | else | |
216 | mouse.Icon = self.Cursors[1] | |
217 | end | |
218 | wait(1/30) | |
219 | end | |
220 | end | |
221 | ||
222 | local InReload=false | |
223 | ||
224 | function GunObj:OnEquipped(mouse) | |
225 | self:Initialize() | |
226 | if mouse ~= nil then | |
227 | self.Equipped = true | |
228 | local Player = game.Players.LocalPlayer | |
229 | if Player ~= nil then | |
230 | local humanoid=WaitForChild(Player.Character,'Humanoid') | |
231 | if not self.IdleAni then | |
232 | self.IdleAni = humanoid:LoadAnimation(WaitForChild(script.Parent,'idle')) | |
233 | self.IdleAni:Play() | |
234 | end | |
235 | local plrgui = WaitForChild(Player,"PlayerGui") | |
236 | self.Gui.Parent = plrgui | |
237 | mouse.Button1Down:connect(function() | |
238 | if not Tool.Down.Value then | |
239 | Tool.Aim.Value = mouse.Hit.p | |
240 | Tool.Down.Value = true | |
241 | while Tool.Down.Value do | |
242 | Tool.Aim.Value = mouse.Hit.p | |
243 | wait() | |
244 | end | |
245 | end | |
246 | end) | |
247 | mouse.Button1Up:connect(function() | |
248 | Tool.Down.Value = false | |
249 | end) | |
250 | mouse.KeyDown:connect(function(key) | |
251 | if key=='r' and not Tool.Reloading.Value and not Tool.Down.Value and self.Ammo.Value ~=8 and self.Ammo.Value ~=0 and not InReload then | |
252 | Tool.Reloading.Value=true | |
253 | end | |
254 | end) | |
255 | --mouse.Icon = self.Cursors[1] | |
256 | Tool.Reloading.Changed:connect(function(val) | |
257 | if mouse ~= nil and self.Equipped then | |
258 | if val then | |
259 | --mouse.Icon = self.Cursors.Reloading | |
260 | else | |
261 | --mouse.Icon = self.Cursors[1] | |
262 | end | |
263 | local Player = game.Players.LocalPlayer | |
264 | if Player ~= nil then | |
265 | local gui = WaitForChild(Player.PlayerGui, "AmmoHud") | |
266 | local humanoid=WaitForChild(Player.Character,'Humanoid') | |
267 | self:UpdateGui() | |
268 | if Tool.Reloading.Value then | |
269 | --gui.Bar.AmmoLabel.Text = "Reloading" | |
270 | end | |
271 | end | |
272 | end | |
273 | end) | |
274 | self:UpdateGui() | |
275 | MyMouse=mouse | |
276 | Spawn(function() self:CursorUpdate(mouse) end ) | |
277 | end | |
278 | end | |
279 | end | |
280 | ||
281 | function GunObj:OnUnequipped() | |
282 | if self.IdleAni then | |
283 | self.IdleAni:Stop() | |
284 | self.IdleAni:Destroy() | |
285 | self.IdleAni=nil | |
286 | end | |
287 | self.Gui.Parent = Tool | |
288 | self.Equipped = false | |
289 | print('in unequipp') | |
290 | if ChestWeld then | |
291 | print('chestweldexists') | |
292 | ChestWeld:Destroy() | |
293 | end | |
294 | local Player = game.Players.localPlayer | |
295 | if Player ~= nil then | |
296 | local gui = WaitForChild(Player.PlayerGui,"AmmoHud") | |
297 | --gui.Bar.GunLabel.Text = "" | |
298 | --gui.Bar.AmmoLabel.Text = "" | |
299 | end | |
300 | end | |
301 | ||
302 | function PlayFireAni() | |
303 | wait(.1) | |
304 | local aniTrack = WaitForChild(Tool.Parent,"Humanoid"):LoadAnimation(Tool.FireAni) | |
305 | aniTrack:Play(0,1,1.2) | |
306 | end | |
307 | ||
308 | local function weldBetween(a, b) | |
309 | local weld = Instance.new("Weld") | |
310 | weld.Part0 = a | |
311 | weld.Part1 = b | |
312 | weld.C0 = CFrame.new() | |
313 | weld.C1 = b.CFrame:inverse() * a.CFrame | |
314 | weld.Parent = a | |
315 | return weld; | |
316 | end | |
317 | ||
318 | ||
319 | function PlayReloadAni() | |
320 | InReload=true | |
321 | local aniTrack = WaitForChild(Tool.Parent,"Humanoid"):LoadAnimation(Tool.Reload) | |
322 | local torso=WaitForChild(Tool.Parent,'Torso') | |
323 | local oldWeld | |
324 | for _,i in pairs(WaitForChild(Tool.Parent,'Right Arm'):GetChildren()) do | |
325 | if i:IsA('Weld') and i.Part1==Tool.Handle then | |
326 | oldWeld=i | |
327 | end | |
328 | end | |
329 | if not oldWeld then | |
330 | print('What... no old weld!') | |
331 | return | |
332 | end | |
333 | ChestWeld= weldBetween(torso,Tool.Handle) | |
334 | oldWeld.Part1=nil | |
335 | aniTrack:Play(0,1,1) | |
336 | wait(0) | |
337 | oldWeld.Part1=Tool.Handle | |
338 | ChestWeld:Destroy() | |
339 | ChestWeld=nil | |
340 | InReload=false | |
341 | end | |
342 | ||
343 | Tool.Reloading.Changed:connect(function() if Tool.Reloading.Value then PlayReloadAni() end end) | |
344 | ||
345 | end)) | |
346 | Vector3Value2.Name = "Aim" | |
347 | Vector3Value2.Parent = Tool0 | |
348 | Vector3Value2.Value = Vector3.new(7370.47461, -428.252258, -6819.59961) | |
349 | IntValue3.Name = "Ammo" | |
350 | IntValue3.Parent = Tool0 | |
351 | IntValue3.Value = 374658376 | |
352 | BoolValue4.Name = "Down" | |
353 | BoolValue4.Parent = Tool0 | |
354 | IntValue5.Name = "NoClips" | |
355 | IntValue5.Parent = Tool0 | |
356 | BoolValue6.Name = "Reloading" | |
357 | BoolValue6.Parent = Tool0 | |
358 | Animation7.Name = "FireAni" | |
359 | Animation7.Parent = Tool0 | |
360 | Animation7.AnimationId = "rbxassetid://94245658" | |
361 | BoolValue8.Name = "DoFireAni" | |
362 | BoolValue8.Parent = Tool0 | |
363 | ScreenGui9.Name = "AmmoHud" | |
364 | ScreenGui9.Parent = Tool0 | |
365 | Frame10.Name = "Bar" | |
366 | Frame10.Parent = ScreenGui9 | |
367 | Frame10.Transparency = 1 | |
368 | Frame10.Size = UDim2.new(0, 200, 0, 60) | |
369 | Frame10.Position = UDim2.new(1, -200, 1, -170) | |
370 | Frame10.BackgroundTransparency = 1 | |
371 | Frame10.ClipsDescendants = true | |
372 | Frame11.Name = "AmmoLeft" | |
373 | Frame11.Parent = Frame10 | |
374 | Frame11.Transparency = 1 | |
375 | Frame11.Size = UDim2.new(0, 65, 0, 50) | |
376 | Frame11.Position = UDim2.new(0, 10, 0, 5) | |
377 | Frame11.BackgroundTransparency = 1 | |
378 | Frame12.Name = "1" | |
379 | Frame12.Parent = Frame11 | |
380 | Frame12.Transparency = 1 | |
381 | Frame12.Size = UDim2.new(0, 30, 0, 40) | |
382 | Frame12.BackgroundTransparency = 1 | |
383 | ImageLabel13.Parent = Frame12 | |
384 | ImageLabel13.Transparency = 1 | |
385 | ImageLabel13.Size = UDim2.new(1, 0, 1, 0) | |
386 | ImageLabel13.BackgroundTransparency = 1 | |
387 | ImageLabel13.ZIndex = 2 | |
388 | ImageLabel13.Image = "http://www.roblox.com/asset/?id=94130434" | |
389 | ImageLabel14.Name = "digit" | |
390 | ImageLabel14.Parent = Frame12 | |
391 | ImageLabel14.Transparency = 1 | |
392 | ImageLabel14.Size = UDim2.new(0.899999976, 0, 0.899999976, 0) | |
393 | ImageLabel14.Position = UDim2.new(0.0500000007, 0, 0.0500000007, 0) | |
394 | ImageLabel14.BackgroundTransparency = 1 | |
395 | ImageLabel14.ZIndex = 2 | |
396 | ImageLabel14.Image = "http://www.roblox.com/asset/?id=94099941" | |
397 | Frame15.Name = "2" | |
398 | Frame15.Parent = Frame11 | |
399 | Frame15.Transparency = 1 | |
400 | Frame15.Size = UDim2.new(0, 30, 0, 40) | |
401 | Frame15.Position = UDim2.new(1, -30, 0, 0) | |
402 | Frame15.BackgroundTransparency = 1 | |
403 | ImageLabel16.Parent = Frame15 | |
404 | ImageLabel16.Transparency = 1 | |
405 | ImageLabel16.Size = UDim2.new(1, 0, 1, 0) | |
406 | ImageLabel16.BackgroundTransparency = 1 | |
407 | ImageLabel16.ZIndex = 2 | |
408 | ImageLabel16.Image = "http://www.roblox.com/asset/?id=94130434" | |
409 | ImageLabel17.Name = "digit" | |
410 | ImageLabel17.Parent = Frame15 | |
411 | ImageLabel17.Transparency = 1 | |
412 | ImageLabel17.Size = UDim2.new(0.899999976, 0, 0.899999976, 0) | |
413 | ImageLabel17.Position = UDim2.new(0.0500000007, 0, 0.0500000007, 0) | |
414 | ImageLabel17.BackgroundTransparency = 1 | |
415 | ImageLabel17.ZIndex = 2 | |
416 | ImageLabel17.Image = "http://www.roblox.com/asset/?id=94099941" | |
417 | ImageLabel18.Name = "slash" | |
418 | ImageLabel18.Parent = Frame10 | |
419 | ImageLabel18.Transparency = 1 | |
420 | ImageLabel18.Size = UDim2.new(0, 30, 0, 40) | |
421 | ImageLabel18.Position = UDim2.new(0.5, -20, 0, 5) | |
422 | ImageLabel18.BackgroundTransparency = 1 | |
423 | ImageLabel18.ZIndex = 2 | |
424 | ImageLabel18.Image = "http://www.roblox.com/asset/?id=94100300" | |
425 | Frame19.Name = "TotalAmmo" | |
426 | Frame19.Parent = Frame10 | |
427 | Frame19.Transparency = 1 | |
428 | Frame19.Size = UDim2.new(0, 65, 0, 50) | |
429 | Frame19.Position = UDim2.new(0.5, 10, 0, 5) | |
430 | Frame19.BackgroundTransparency = 1 | |
431 | Frame20.Name = "1" | |
432 | Frame20.Parent = Frame19 | |
433 | Frame20.Transparency = 1 | |
434 | Frame20.Size = UDim2.new(0, 30, 0, 40) | |
435 | Frame20.BackgroundTransparency = 1 | |
436 | Frame20.ClipsDescendants = true | |
437 | ImageLabel21.Parent = Frame20 | |
438 | ImageLabel21.Transparency = 1 | |
439 | ImageLabel21.Size = UDim2.new(1, 0, 1, 0) | |
440 | ImageLabel21.BackgroundTransparency = 1 | |
441 | ImageLabel21.ZIndex = 2 | |
442 | ImageLabel21.Image = "http://www.roblox.com/asset/?id=94130434" | |
443 | ImageLabel22.Name = "digit" | |
444 | ImageLabel22.Parent = Frame20 | |
445 | ImageLabel22.Transparency = 1 | |
446 | ImageLabel22.Size = UDim2.new(0.899999976, 0, 0.899999976, 0) | |
447 | ImageLabel22.Position = UDim2.new(0.0500000007, 0, 0.0500000007, 0) | |
448 | ImageLabel22.BackgroundTransparency = 1 | |
449 | ImageLabel22.ZIndex = 2 | |
450 | ImageLabel22.Image = "http://www.roblox.com/asset/?id=94099941" | |
451 | Frame23.Name = "2" | |
452 | Frame23.Parent = Frame19 | |
453 | Frame23.Transparency = 1 | |
454 | Frame23.Size = UDim2.new(0, 30, 0, 40) | |
455 | Frame23.Position = UDim2.new(1, -30, 0, 0) | |
456 | Frame23.BackgroundTransparency = 1 | |
457 | ImageLabel24.Parent = Frame23 | |
458 | ImageLabel24.Transparency = 1 | |
459 | ImageLabel24.Size = UDim2.new(1, 0, 1, 0) | |
460 | ImageLabel24.BackgroundTransparency = 1 | |
461 | ImageLabel24.ZIndex = 2 | |
462 | ImageLabel24.Image = "http://www.roblox.com/asset/?id=94130434" | |
463 | ImageLabel25.Name = "digit" | |
464 | ImageLabel25.Parent = Frame23 | |
465 | ImageLabel25.Transparency = 1 | |
466 | ImageLabel25.Size = UDim2.new(0.899999976, 0, 0.899999976, 0) | |
467 | ImageLabel25.Position = UDim2.new(0.0500000007, 0, 0.0500000007, 0) | |
468 | ImageLabel25.BackgroundTransparency = 1 | |
469 | ImageLabel25.ZIndex = 2 | |
470 | ImageLabel25.Image = "http://www.roblox.com/asset/?id=94099941" | |
471 | Animation26.Name = "idle" | |
472 | Animation26.Parent = Tool0 | |
473 | Animation26.AnimationId = "rbxassetid://94242777" | |
474 | Animation27.Name = "Reload" | |
475 | Animation27.Parent = Tool0 | |
476 | Animation27.AnimationId = "rbxassetid://94245658" | |
477 | SpecialMesh28.Name = "BulletMesh" | |
478 | SpecialMesh28.Parent = Tool0 | |
479 | SpecialMesh28.MeshId = "http://www.roblox.com/asset/?id=95392019" | |
480 | SpecialMesh28.Scale = Vector3.new(1.5, 1.5, 1.5) | |
481 | SpecialMesh28.TextureId = "http://www.roblox.com/asset/?id=95391833" | |
482 | SpecialMesh28.MeshType = Enum.MeshType.FileMesh | |
483 | SpecialMesh28.Scale = Vector3.new(1.5, 1.5, 1.5) | |
484 | Script29.Name = "Firescript" | |
485 | Script29.Parent = Tool0 | |
486 | table.insert(cors,sandbox(Script29,function() | |
487 | -- Made by Stickmasterluke | |
488 | -- edited by fusroblox | |
489 | local GoreOn=true | |
490 | function WaitForChild(parent,child) | |
491 | while not parent:FindFirstChild(child) do print("2waiting for " .. child) wait() end | |
492 | return parent[child] | |
493 | end | |
494 | ||
495 | local GunObject = { | |
496 | Tool = script.Parent, | |
497 | Handle = WaitForChild(script.Parent,'Handle'), | |
498 | check = true, | |
499 | ||
500 | GunDamage = 27, -- Base output damage per shot. | |
501 | FireRate = .7, -- How often the weapon can fire. | |
502 | Automatic = false, -- hold down to continue firing | |
503 | Range = 250, -- Max distance that the weapon can fire. | |
504 | Spread = 7, -- The bigger the spread, the more inaccurate the shots will be. | |
505 | ClipSize = 36, -- Shots in a clip | |
506 | ReloadTime = 0, -- Time it takes to reload the tool. | |
507 | StartingClips = 10, -- If you want infinit clips, remove the IntValue named "Clips" from the tool. | |
508 | SegmentLength = 40, -- How long the shot segments are, or the speed of the shot. | |
509 | FadeDelayTime = 1/30, | |
510 | ||
511 | ||
512 | BarrelPos = CFrame.new(0, 0, - 1.2), -- L, F, U | |
513 | Rate = 1/30, | |
514 | --local Colors = {BrickColor.new("Bright red"), BrickColor.new("Really red"), BrickColor.new("Dusty Rose"), BrickColor.new("Medium red")} | |
515 | Colors = {BrickColor.new("Bright yellow"),BrickColor.new("Mid gray"), BrickColor.new("Medium stone grey"), BrickColor.new("Dark stone grey")}, | |
516 | FlashColors = {"Medium red", "Dusty Rose", "Bright red", "Really red"}, | |
517 | ||
518 | Reloading = false, | |
519 | Debris = game:GetService("Debris"), | |
520 | Ammo, | |
521 | Clips, | |
522 | LaserObj, | |
523 | SparkEffect, | |
524 | ShellPart, | |
525 | --tool children | |
526 | DownVal=WaitForChild(script.Parent, 'Down'), | |
527 | AimVal=WaitForChild(script.Parent, 'Aim'), | |
528 | ReloadingVal=WaitForChild(script.Parent, 'Reloading'), | |
529 | DoFireAni = WaitForChild(script.Parent,'DoFireAni'), | |
530 | ||
531 | --handlechildren | |
532 | Fire, | |
533 | ||
534 | } | |
535 | ||
536 | --[[Member functions]] | |
537 | ||
538 | function GunObject:Initialize() | |
539 | ||
540 | self.Fire=WaitForChild(self.Handle, 'Fire') | |
541 | ||
542 | self.Ammo = self.Tool:FindFirstChild("Ammo") | |
543 | if self.Ammo ~= nil then | |
544 | self.Ammo.Value = self.ClipSize | |
545 | end | |
546 | self.Clips = self.Tool:FindFirstChild("Clips") | |
547 | if self.Clips ~= nil then | |
548 | self.Clips.Value = self.StartingClips | |
549 | end | |
550 | self.Tool.Equipped:connect(function() | |
551 | self.Tool.Handle.Fire:Stop() | |
552 | self.Tool.Handle.Reload:Stop() | |
553 | end) | |
554 | self.Tool.Unequipped:connect(function() | |
555 | self.Tool.Handle.Fire:Stop() | |
556 | self.Tool.Handle.Reload:Stop() | |
557 | end) | |
558 | self.LaserObj = Instance.new("Part") | |
559 | self.LaserObj.Name = "Bullet" | |
560 | self.LaserObj.Anchored = true | |
561 | self.LaserObj.CanCollide = false | |
562 | self.LaserObj.Shape = "Block" | |
563 | self.LaserObj.formFactor = "Custom" | |
564 | self.LaserObj.Material = Enum.Material.Neon | |
565 | self.LaserObj.Locked = true | |
566 | self.LaserObj.TopSurface = 0 | |
567 | self.LaserObj.BottomSurface = 0 | |
568 | ||
569 | local tSparkEffect = Instance.new("Part") | |
570 | tSparkEffect.Name = "Effect" | |
571 | tSparkEffect.Anchored = false | |
572 | tSparkEffect.CanCollide = false | |
573 | tSparkEffect.Shape = "Block" | |
574 | tSparkEffect.formFactor = "Custom" | |
575 | tSparkEffect.Material = Enum.Material.Neon | |
576 | tSparkEffect.Locked = true | |
577 | tSparkEffect.TopSurface = 0 | |
578 | tSparkEffect.BottomSurface = 0 | |
579 | self.SparkEffect=tSparkEffect | |
580 | ||
581 | local tshell = Instance.new('Part') | |
582 | tshell.Name='effect' | |
583 | tshell.FormFactor='Custom' | |
584 | tshell.Size=Vector3.new(1, 0.4, 0.33) | |
585 | tshell.BrickColor=BrickColor.new('Bright yellow') | |
586 | local tshellmesh=WaitForChild(script.Parent,'BulletMesh'):Clone() | |
587 | tshellmesh.Parent=tshell | |
588 | self.ShellPart = tshell | |
589 | ||
590 | self.DownVal.Changed:connect(function() | |
591 | while self.DownVal.Value and self.check and not self.Reloading do | |
592 | self.check = false | |
593 | local humanoid = self.Tool.Parent:FindFirstChild("Humanoid") | |
594 | local plr1 = game.Players:GetPlayerFromCharacter(self.Tool.Parent) | |
595 | if humanoid ~= nil and plr1 ~= nil then | |
596 | if humanoid.Health > 0 then | |
597 | local spos1 = (self.Tool.Handle.CFrame * self.BarrelPos).p | |
598 | delay(0, function() self:SendBullet(spos1, self.AimVal.Value, self.Spread, self.SegmentLength, self.Tool.Parent, self.Colors[1], self.GunDamage, self.FadeDelayTime) end) | |
599 | else | |
600 | self.check = true | |
601 | break | |
602 | end | |
603 | else | |
604 | self.check = true | |
605 | break | |
606 | end | |
607 | wait(self.FireRate) | |
608 | self.check = true | |
609 | if not self.Automatic then | |
610 | break | |
611 | end | |
612 | end | |
613 | end) | |
614 | ||
615 | self.ReloadingVal.Changed:connect(function() if self.ReloadingVal.Value then self:Reload() end end) | |
616 | ||
617 | end | |
618 | ||
619 | ||
620 | ||
621 | function GunObject:Reload() | |
622 | self.Reloading = true | |
623 | self.ReloadingVal.Value = true | |
624 | if self.Clips ~= nil then | |
625 | if self.Clips.Value > 0 then | |
626 | self.Clips.Value = Clips.Value - 1 | |
627 | else | |
628 | self.Reloading = false | |
629 | self.ReloadingVal.Value = false | |
630 | return | |
631 | end | |
632 | end | |
633 | self.Tool.Handle.Reload:Play() | |
634 | for i = 1, self.ClipSize do | |
635 | wait(self.ReloadTime/self.ClipSize) | |
636 | self.Ammo.Value = i | |
637 | end | |
638 | self.Reloading = false | |
639 | self.Tool.Reloading.Value = false | |
640 | end | |
641 | ||
642 | ||
643 | ||
644 | function GunObject:SpawnShell() | |
645 | local tshell=self.ShellPart:Clone() | |
646 | tshell.CFrame=self.Handle.CFrame | |
647 | tshell.Parent=Workspace | |
648 | game.Debris:AddItem(tshell,2) | |
649 | end | |
650 | ||
651 | function KnockOffHats(tchar) | |
652 | for _,i in pairs(tchar:GetChildren()) do | |
653 | if i:IsA('Hat') then | |
654 | i.Parent=game.Workspace | |
655 | end | |
656 | end | |
657 | end | |
658 | ||
659 | function KnockOffTool(tchar) | |
660 | for _,i in pairs(tchar:GetChildren()) do | |
661 | if i:IsA('Tool') then | |
662 | i.Parent=game.Workspace | |
663 | end | |
664 | end | |
665 | end | |
666 | ||
667 | function GunObject:SendBullet(boltstart, targetpos, fuzzyness, SegmentLength, ignore, clr, damage, fadedelay) | |
668 | if self.Ammo.Value <=0 then return end | |
669 | self.Ammo.Value = self.Ammo.Value - 1 | |
670 | self:SpawnShell() | |
671 | self.Fire.Pitch = 1 | |
672 | self.Fire:Play() | |
673 | self.Volume = 10 | |
674 | self.Fire.TimePosition = 0 | |
675 | self.DoFireAni.Value = not self.DoFireAni.Value | |
676 | print(self.Fire.Pitch) | |
677 | local boltdist = self.Range | |
678 | local clickdist = (boltstart - targetpos).magnitude | |
679 | local targetpos = targetpos + (Vector3.new(math.random() - .5, math.random() - .5, math.random() - .5) * (clickdist/100) * fuzzyness) | |
680 | local boltvec = (targetpos - boltstart).unit | |
681 | local totalsegments = math.ceil(boltdist/SegmentLength) | |
682 | local lastpos = boltstart | |
683 | for i = 1, totalsegments do | |
684 | local newpos = (boltstart + (boltvec * (boltdist * (i/totalsegments)))) | |
685 | local segvec = (newpos - lastpos).unit | |
686 | local boltlength = (newpos - lastpos).magnitude | |
687 | local bolthit, endpos = CastRay(lastpos, segvec, boltlength, ignore, false) | |
688 | DrawBeam(lastpos, endpos, clr, fadedelay, self.LaserObj) | |
689 | if bolthit ~= nil then | |
690 | local h = bolthit.Parent:FindFirstChild("Humanoid") | |
691 | if h ~= nil then | |
692 | local plr = game.Players:GetPlayerFromCharacter(self.Tool.Parent) | |
693 | if plr ~= nil then | |
694 | local creator = Instance.new("ObjectValue") | |
695 | creator.Name = "creator" | |
696 | creator.Value = plr | |
697 | creator.Parent = h | |
698 | end | |
699 | if hit.Parent:FindFirstChild("BlockShot") then | |
700 | hit.Parent:FindFirstChild("BlockShot"):Fire(newpos) | |
701 | delay(0, function() self:HitEffect(endpos, BrickColor.new('Bright yellow'),5) end) | |
702 | else | |
703 | if(hit.Name=='Head') then | |
704 | KnockOffHats(hit.Parent) | |
705 | end | |
706 | if GoreOn then delay(0,function() self:HitEffect(endpos, BrickColor.new('Bright red'),20) end) end | |
707 | h:TakeDamage(damage) | |
708 | end | |
709 | else | |
710 | delay(0, function() self:HitEffect(endpos, BrickColor.new('Bright yellow'),5) end) | |
711 | end | |
712 | break | |
713 | end | |
714 | lastpos = endpos | |
715 | wait(Rate) | |
716 | end | |
717 | ||
718 | if self.Ammo.Value < 1 then | |
719 | self:Reload() | |
720 | end | |
721 | ||
722 | end | |
723 | ||
724 | ||
725 | ||
726 | function GunObject:MakeSpark(pos,tcolor) | |
727 | local effect=self.SparkEffect:Clone() | |
728 | effect.BrickColor = tcolor | |
729 | effect.CFrame = CFrame.new(pos) | |
730 | effect.Parent = game.Workspace | |
731 | local effectVel = Instance.new("BodyVelocity") | |
732 | effectVel.maxForce = Vector3.new(99999, 99999, 99999) | |
733 | effectVel.velocity = Vector3.new(math.random() * 15 * SigNum(math.random( - 10, 10)), math.random() * 15 * SigNum(math.random( - 10, 10)), math.random() * 15 * SigNum(math.random( - 10, 10))) | |
734 | effectVel.Parent = effect | |
735 | effect.Size = Vector3.new(math.abs(effectVel.velocity.x)/30, math.abs(effectVel.velocity.y)/30, math.abs(effectVel.velocity.z)/30) | |
736 | wait() | |
737 | effectVel:Destroy() | |
738 | local effecttime = .5 | |
739 | game.Debris:AddItem(effect, effecttime * 2) | |
740 | local startTime = time() | |
741 | while time() - startTime < effecttime do | |
742 | if effect ~= nil then | |
743 | effect.Transparency = (time() - startTime)/effecttime | |
744 | end | |
745 | wait() | |
746 | end | |
747 | if effect ~= nil then | |
748 | effect.Parent = nil | |
749 | end | |
750 | end | |
751 | ||
752 | function GunObject:HitEffect(pos,tcolor,numSparks) | |
753 | for i = 0, numSparks, 1 do | |
754 | Spawn(function() self:MakeSpark(pos,tcolor) end) | |
755 | end | |
756 | ||
757 | end | |
758 | ||
759 | --[[/Member functions]] | |
760 | ||
761 | ||
762 | --[[Static functions]] | |
763 | ||
764 | function Round(number, decimal) | |
765 | decimal = decimal or 0 | |
766 | local mult = 10^decimal | |
767 | return math.floor(number * mult + .5)/mult | |
768 | end | |
769 | ||
770 | function SigNum(num) | |
771 | if num == 0 then return 1 end | |
772 | return math.abs(num)/num | |
773 | end | |
774 | ||
775 | --this is a little bad, but shouldn't really be part of the 'class' of the gun | |
776 | local Intangibles = {shock=1, bolt=1, bullet=1, plasma=1, effect=1, laser=1, handle=1, effects=1, flash=1,} | |
777 | function CheckIntangible(hitObj) | |
778 | print(hitObj.Name) | |
779 | return Intangibles[(string.lower(hitObj.Name))] or hitObj.Transparency == 1 | |
780 | end | |
781 | ||
782 | function CastRay(startpos, vec, length, ignore, delayifhit) | |
783 | if length > 999 then | |
784 | length = 999 | |
785 | end | |
786 | hit, endpos2 = game.Workspace:FindPartOnRay(Ray.new(startpos, vec * length), ignore) | |
787 | if hit ~= nil then | |
788 | if CheckIntangible(hit) then | |
789 | if delayifhit then | |
790 | wait() | |
791 | end | |
792 | hit, endpos2 = CastRay(endpos2 + (vec * .01), vec, length - ((startpos - endpos2).magnitude), ignore, delayifhit) | |
793 | end | |
794 | end | |
795 | return hit, endpos2 | |
796 | end | |
797 | ||
798 | function DrawBeam(beamstart, beamend, clr, fadedelay, templatePart) | |
799 | local dis = 2 --(beamstart - beamend).magnitude | |
800 | local tlaser=templatePart:Clone() | |
801 | tlaser.BrickColor = clr | |
802 | tlaser.Size = Vector3.new(.1, .1, dis + .2) | |
803 | tlaser.CFrame = CFrame.new((beamend+beamstart)/2, beamstart) * CFrame.new(0, 0, - dis/2) | |
804 | tlaser.Parent = game.Workspace | |
805 | game.Debris:AddItem(tlaser, fadedelay) | |
806 | end | |
807 | ||
808 | --[[/Static functions]] | |
809 | ||
810 | ||
811 | GunObject:Initialize() | |
812 | end)) | |
813 | Script30.Name = "Firescript" | |
814 | Script30.Parent = Tool0 | |
815 | table.insert(cors,sandbox(Script30,function() | |
816 | -- Made by Stickmasterluke | |
817 | -- edited by fusroblox | |
818 | local GoreOn=true | |
819 | function WaitForChild(parent,child) | |
820 | while not parent:FindFirstChild(child) do print("2waiting for " .. child) wait() end | |
821 | return parent[child] | |
822 | end | |
823 | ||
824 | local GunObject = { | |
825 | Tool = script.Parent, | |
826 | Handle = WaitForChild(script.Parent,'Handle'), | |
827 | check = true, | |
828 | ||
829 | GunDamage = 27, -- Base output damage per shot. | |
830 | FireRate = .7, -- How often the weapon can fire. | |
831 | Automatic = false, -- hold down to continue firing | |
832 | Range = 250, -- Max distance that the weapon can fire. | |
833 | Spread = 7, -- The bigger the spread, the more inaccurate the shots will be. | |
834 | ClipSize = 36, -- Shots in a clip | |
835 | ReloadTime = 0, -- Time it takes to reload the tool. | |
836 | StartingClips = 10, -- If you want infinit clips, remove the IntValue named "Clips" from the tool. | |
837 | SegmentLength = 40, -- How long the shot segments are, or the speed of the shot. | |
838 | FadeDelayTime = 1/30, | |
839 | ||
840 | ||
841 | BarrelPos = CFrame.new(0, 0, - 1.2), -- L, F, U | |
842 | Rate = 1/30, | |
843 | --local Colors = {BrickColor.new("Bright red"), BrickColor.new("Really red"), BrickColor.new("Dusty Rose"), BrickColor.new("Medium red")} | |
844 | Colors = {BrickColor.new("Bright yellow"),BrickColor.new("Mid gray"), BrickColor.new("Medium stone grey"), BrickColor.new("Dark stone grey")}, | |
845 | FlashColors = {"Medium red", "Dusty Rose", "Bright red", "Really red"}, | |
846 | ||
847 | Reloading = false, | |
848 | Debris = game:GetService("Debris"), | |
849 | Ammo, | |
850 | Clips, | |
851 | LaserObj, | |
852 | SparkEffect, | |
853 | ShellPart, | |
854 | --tool children | |
855 | DownVal=WaitForChild(script.Parent, 'Down'), | |
856 | AimVal=WaitForChild(script.Parent, 'Aim'), | |
857 | ReloadingVal=WaitForChild(script.Parent, 'Reloading'), | |
858 | DoFireAni = WaitForChild(script.Parent,'DoFireAni'), | |
859 | ||
860 | --handlechildren | |
861 | Fire, | |
862 | ||
863 | } | |
864 | ||
865 | --[[Member functions]] | |
866 | ||
867 | function GunObject:Initialize() | |
868 | ||
869 | self.Fire=WaitForChild(self.Handle, 'Fire') | |
870 | ||
871 | self.Ammo = self.Tool:FindFirstChild("Ammo") | |
872 | if self.Ammo ~= nil then | |
873 | self.Ammo.Value = self.ClipSize | |
874 | end | |
875 | self.Clips = self.Tool:FindFirstChild("Clips") | |
876 | if self.Clips ~= nil then | |
877 | self.Clips.Value = self.StartingClips | |
878 | end | |
879 | self.Tool.Equipped:connect(function() | |
880 | self.Tool.Handle.Fire:Stop() | |
881 | self.Tool.Handle.Reload:Stop() | |
882 | end) | |
883 | self.Tool.Unequipped:connect(function() | |
884 | self.Tool.Handle.Fire:Stop() | |
885 | self.Tool.Handle.Reload:Stop() | |
886 | end) | |
887 | self.LaserObj = Instance.new("Part") | |
888 | self.LaserObj.Name = "Bullet" | |
889 | self.LaserObj.Anchored = true | |
890 | self.LaserObj.CanCollide = false | |
891 | self.LaserObj.Shape = "Block" | |
892 | self.LaserObj.formFactor = "Custom" | |
893 | self.LaserObj.Material = Enum.Material.Neon | |
894 | self.LaserObj.Locked = true | |
895 | self.LaserObj.TopSurface = 0 | |
896 | self.LaserObj.BottomSurface = 0 | |
897 | ||
898 | local tSparkEffect = Instance.new("Part") | |
899 | tSparkEffect.Name = "Effect" | |
900 | tSparkEffect.Anchored = false | |
901 | tSparkEffect.CanCollide = false | |
902 | tSparkEffect.Shape = "Block" | |
903 | tSparkEffect.formFactor = "Custom" | |
904 | tSparkEffect.Material = Enum.Material.Neon | |
905 | tSparkEffect.Locked = true | |
906 | tSparkEffect.TopSurface = 0 | |
907 | tSparkEffect.BottomSurface = 0 | |
908 | self.SparkEffect=tSparkEffect | |
909 | ||
910 | local tshell = Instance.new('Part') | |
911 | tshell.Name='effect' | |
912 | tshell.FormFactor='Custom' | |
913 | tshell.Size=Vector3.new(1, 0.4, 0.33) | |
914 | tshell.BrickColor=BrickColor.new('Bright yellow') | |
915 | local tshellmesh=WaitForChild(script.Parent,'BulletMesh'):Clone() | |
916 | tshellmesh.Parent=tshell | |
917 | self.ShellPart = tshell | |
918 | ||
919 | self.DownVal.Changed:connect(function() | |
920 | while self.DownVal.Value and self.check and not self.Reloading do | |
921 | self.check = false | |
922 | local humanoid = self.Tool.Parent:FindFirstChild("Humanoid") | |
923 | local plr1 = game.Players:GetPlayerFromCharacter(self.Tool.Parent) | |
924 | if humanoid ~= nil and plr1 ~= nil then | |
925 | if humanoid.Health > 0 then | |
926 | local spos1 = (self.Tool.Handle.CFrame * self.BarrelPos).p | |
927 | delay(0, function() self:SendBullet(spos1, self.AimVal.Value, self.Spread, self.SegmentLength, self.Tool.Parent, self.Colors[1], self.GunDamage, self.FadeDelayTime) end) | |
928 | else | |
929 | self.check = true | |
930 | break | |
931 | end | |
932 | else | |
933 | self.check = true | |
934 | break | |
935 | end | |
936 | wait(self.FireRate) | |
937 | self.check = true | |
938 | if not self.Automatic then | |
939 | break | |
940 | end | |
941 | end | |
942 | end) | |
943 | ||
944 | self.ReloadingVal.Changed:connect(function() if self.ReloadingVal.Value then self:Reload() end end) | |
945 | ||
946 | end | |
947 | ||
948 | ||
949 | ||
950 | function GunObject:Reload() | |
951 | self.Reloading = true | |
952 | self.ReloadingVal.Value = true | |
953 | if self.Clips ~= nil then | |
954 | if self.Clips.Value > 0 then | |
955 | self.Clips.Value = Clips.Value - 1 | |
956 | else | |
957 | self.Reloading = false | |
958 | self.ReloadingVal.Value = false | |
959 | return | |
960 | end | |
961 | end | |
962 | self.Tool.Handle.Reload:Play() | |
963 | for i = 1, self.ClipSize do | |
964 | wait(self.ReloadTime/self.ClipSize) | |
965 | self.Ammo.Value = i | |
966 | end | |
967 | self.Reloading = false | |
968 | self.Tool.Reloading.Value = false | |
969 | end | |
970 | ||
971 | ||
972 | ||
973 | function GunObject:SpawnShell() | |
974 | local tshell=self.ShellPart:Clone() | |
975 | tshell.CFrame=self.Handle.CFrame | |
976 | tshell.Parent=Workspace | |
977 | game.Debris:AddItem(tshell,2) | |
978 | end | |
979 | ||
980 | function KnockOffHats(tchar) | |
981 | for _,i in pairs(tchar:GetChildren()) do | |
982 | if i:IsA('Hat') then | |
983 | i.Parent=game.Workspace | |
984 | end | |
985 | end | |
986 | end | |
987 | ||
988 | function KnockOffTool(tchar) | |
989 | for _,i in pairs(tchar:GetChildren()) do | |
990 | if i:IsA('Tool') then | |
991 | i.Parent=game.Workspace | |
992 | end | |
993 | end | |
994 | end | |
995 | ||
996 | function GunObject:SendBullet(boltstart, targetpos, fuzzyness, SegmentLength, ignore, clr, damage, fadedelay) | |
997 | if self.Ammo.Value <=0 then return end | |
998 | self.Ammo.Value = self.Ammo.Value - 1 | |
999 | self:SpawnShell() | |
1000 | self.Fire.Pitch = 1 | |
1001 | self.Fire:Play() | |
1002 | self.Volume = 10 | |
1003 | self.Fire.TimePosition = 0 | |
1004 | self.DoFireAni.Value = not self.DoFireAni.Value | |
1005 | print(self.Fire.Pitch) | |
1006 | local boltdist = self.Range | |
1007 | local clickdist = (boltstart - targetpos).magnitude | |
1008 | local targetpos = targetpos + (Vector3.new(math.random() - .5, math.random() - .5, math.random() - .5) * (clickdist/100) * fuzzyness) | |
1009 | local boltvec = (targetpos - boltstart).unit | |
1010 | local totalsegments = math.ceil(boltdist/SegmentLength) | |
1011 | local lastpos = boltstart | |
1012 | for i = 1, totalsegments do | |
1013 | local newpos = (boltstart + (boltvec * (boltdist * (i/totalsegments)))) | |
1014 | local segvec = (newpos - lastpos).unit | |
1015 | local boltlength = (newpos - lastpos).magnitude | |
1016 | local bolthit, endpos = CastRay(lastpos, segvec, boltlength, ignore, false) | |
1017 | DrawBeam(lastpos, endpos, clr, fadedelay, self.LaserObj) | |
1018 | if bolthit ~= nil then | |
1019 | local h = bolthit.Parent:FindFirstChild("Humanoid") | |
1020 | if h ~= nil then | |
1021 | local plr = game.Players:GetPlayerFromCharacter(self.Tool.Parent) | |
1022 | if plr ~= nil then | |
1023 | local creator = Instance.new("ObjectValue") | |
1024 | creator.Name = "creator" | |
1025 | creator.Value = plr | |
1026 | creator.Parent = h | |
1027 | end | |
1028 | if hit.Parent:FindFirstChild("BlockShot") then | |
1029 | hit.Parent:FindFirstChild("BlockShot"):Fire(newpos) | |
1030 | delay(0, function() self:HitEffect(endpos, BrickColor.new('Bright yellow'),5) end) | |
1031 | else | |
1032 | if(hit.Name=='Head') then | |
1033 | KnockOffHats(hit.Parent) | |
1034 | end | |
1035 | if GoreOn then delay(0,function() self:HitEffect(endpos, BrickColor.new('Bright red'),20) end) end | |
1036 | h:TakeDamage(damage) | |
1037 | end | |
1038 | else | |
1039 | delay(0, function() self:HitEffect(endpos, BrickColor.new('Bright yellow'),5) end) | |
1040 | end | |
1041 | break | |
1042 | end | |
1043 | lastpos = endpos | |
1044 | wait(Rate) | |
1045 | end | |
1046 | ||
1047 | if self.Ammo.Value < 1 then | |
1048 | self:Reload() | |
1049 | end | |
1050 | ||
1051 | end | |
1052 | ||
1053 | ||
1054 | ||
1055 | function GunObject:MakeSpark(pos,tcolor) | |
1056 | local effect=self.SparkEffect:Clone() | |
1057 | effect.BrickColor = tcolor | |
1058 | effect.CFrame = CFrame.new(pos) | |
1059 | effect.Parent = game.Workspace | |
1060 | local effectVel = Instance.new("BodyVelocity") | |
1061 | effectVel.maxForce = Vector3.new(99999, 99999, 99999) | |
1062 | effectVel.velocity = Vector3.new(math.random() * 15 * SigNum(math.random( - 10, 10)), math.random() * 15 * SigNum(math.random( - 10, 10)), math.random() * 15 * SigNum(math.random( - 10, 10))) | |
1063 | effectVel.Parent = effect | |
1064 | effect.Size = Vector3.new(math.abs(effectVel.velocity.x)/30, math.abs(effectVel.velocity.y)/30, math.abs(effectVel.velocity.z)/30) | |
1065 | wait() | |
1066 | effectVel:Destroy() | |
1067 | local effecttime = .5 | |
1068 | game.Debris:AddItem(effect, effecttime * 2) | |
1069 | local startTime = time() | |
1070 | while time() - startTime < effecttime do | |
1071 | if effect ~= nil then | |
1072 | effect.Transparency = (time() - startTime)/effecttime | |
1073 | end | |
1074 | wait() | |
1075 | end | |
1076 | if effect ~= nil then | |
1077 | effect.Parent = nil | |
1078 | end | |
1079 | end | |
1080 | ||
1081 | function GunObject:HitEffect(pos,tcolor,numSparks) | |
1082 | for i = 0, numSparks, 1 do | |
1083 | Spawn(function() self:MakeSpark(pos,tcolor) end) | |
1084 | end | |
1085 | ||
1086 | end | |
1087 | ||
1088 | --[[/Member functions]] | |
1089 | ||
1090 | ||
1091 | --[[Static functions]] | |
1092 | ||
1093 | function Round(number, decimal) | |
1094 | decimal = decimal or 0 | |
1095 | local mult = 10^decimal | |
1096 | return math.floor(number * mult + .5)/mult | |
1097 | end | |
1098 | ||
1099 | function SigNum(num) | |
1100 | if num == 0 then return 1 end | |
1101 | return math.abs(num)/num | |
1102 | end | |
1103 | ||
1104 | --this is a little bad, but shouldn't really be part of the 'class' of the gun | |
1105 | local Intangibles = {shock=1, bolt=1, bullet=1, plasma=1, effect=1, laser=1, handle=1, effects=1, flash=1,} | |
1106 | function CheckIntangible(hitObj) | |
1107 | print(hitObj.Name) | |
1108 | return Intangibles[(string.lower(hitObj.Name))] or hitObj.Transparency == 1 | |
1109 | end | |
1110 | ||
1111 | function CastRay(startpos, vec, length, ignore, delayifhit) | |
1112 | if length > 999 then | |
1113 | length = 999 | |
1114 | end | |
1115 | hit, endpos2 = game.Workspace:FindPartOnRay(Ray.new(startpos, vec * length), ignore) | |
1116 | if hit ~= nil then | |
1117 | if CheckIntangible(hit) then | |
1118 | if delayifhit then | |
1119 | wait() | |
1120 | end | |
1121 | hit, endpos2 = CastRay(endpos2 + (vec * .01), vec, length - ((startpos - endpos2).magnitude), ignore, delayifhit) | |
1122 | end | |
1123 | end | |
1124 | return hit, endpos2 | |
1125 | end | |
1126 | ||
1127 | function DrawBeam(beamstart, beamend, clr, fadedelay, templatePart) | |
1128 | local dis = 2 --(beamstart - beamend).magnitude | |
1129 | local tlaser=templatePart:Clone() | |
1130 | tlaser.BrickColor = clr | |
1131 | tlaser.Size = Vector3.new(.1, .1, dis + .2) | |
1132 | tlaser.CFrame = CFrame.new((beamend+beamstart)/2, beamstart) * CFrame.new(0, 0, - dis/2) | |
1133 | tlaser.Parent = game.Workspace | |
1134 | game.Debris:AddItem(tlaser, fadedelay) | |
1135 | end | |
1136 | ||
1137 | --[[/Static functions]] | |
1138 | ||
1139 | ||
1140 | GunObject:Initialize() | |
1141 | end)) | |
1142 | Script31.Name = "Firescript" | |
1143 | Script31.Parent = Tool0 | |
1144 | table.insert(cors,sandbox(Script31,function() | |
1145 | -- Made by Stickmasterluke | |
1146 | -- edited by fusroblox | |
1147 | local GoreOn=true | |
1148 | function WaitForChild(parent,child) | |
1149 | while not parent:FindFirstChild(child) do print("2waiting for " .. child) wait() end | |
1150 | return parent[child] | |
1151 | end | |
1152 | ||
1153 | local GunObject = { | |
1154 | Tool = script.Parent, | |
1155 | Handle = WaitForChild(script.Parent,'Handle'), | |
1156 | check = true, | |
1157 | ||
1158 | GunDamage = 27, -- Base output damage per shot. | |
1159 | FireRate = .7, -- How often the weapon can fire. | |
1160 | Automatic = false, -- hold down to continue firing | |
1161 | Range = 250, -- Max distance that the weapon can fire. | |
1162 | Spread = 7, -- The bigger the spread, the more inaccurate the shots will be. | |
1163 | ClipSize = 36, -- Shots in a clip | |
1164 | ReloadTime = 0, -- Time it takes to reload the tool. | |
1165 | StartingClips = 10, -- If you want infinit clips, remove the IntValue named "Clips" from the tool. | |
1166 | SegmentLength = 40, -- How long the shot segments are, or the speed of the shot. | |
1167 | FadeDelayTime = 1/30, | |
1168 | ||
1169 | ||
1170 | BarrelPos = CFrame.new(0, 0, - 1.2), -- L, F, U | |
1171 | Rate = 1/30, | |
1172 | --local Colors = {BrickColor.new("Bright red"), BrickColor.new("Really red"), BrickColor.new("Dusty Rose"), BrickColor.new("Medium red")} | |
1173 | Colors = {BrickColor.new("Bright yellow"),BrickColor.new("Mid gray"), BrickColor.new("Medium stone grey"), BrickColor.new("Dark stone grey")}, | |
1174 | FlashColors = {"Medium red", "Dusty Rose", "Bright red", "Really red"}, | |
1175 | ||
1176 | Reloading = false, | |
1177 | Debris = game:GetService("Debris"), | |
1178 | Ammo, | |
1179 | Clips, | |
1180 | LaserObj, | |
1181 | SparkEffect, | |
1182 | ShellPart, | |
1183 | --tool children | |
1184 | DownVal=WaitForChild(script.Parent, 'Down'), | |
1185 | AimVal=WaitForChild(script.Parent, 'Aim'), | |
1186 | ReloadingVal=WaitForChild(script.Parent, 'Reloading'), | |
1187 | DoFireAni = WaitForChild(script.Parent,'DoFireAni'), | |
1188 | ||
1189 | --handlechildren | |
1190 | Fire, | |
1191 | ||
1192 | } | |
1193 | ||
1194 | --[[Member functions]] | |
1195 | ||
1196 | function GunObject:Initialize() | |
1197 | ||
1198 | self.Fire=WaitForChild(self.Handle, 'Fire') | |
1199 | ||
1200 | self.Ammo = self.Tool:FindFirstChild("Ammo") | |
1201 | if self.Ammo ~= nil then | |
1202 | self.Ammo.Value = self.ClipSize | |
1203 | end | |
1204 | self.Clips = self.Tool:FindFirstChild("Clips") | |
1205 | if self.Clips ~= nil then | |
1206 | self.Clips.Value = self.StartingClips | |
1207 | end | |
1208 | self.Tool.Equipped:connect(function() | |
1209 | self.Tool.Handle.Fire:Stop() | |
1210 | self.Tool.Handle.Reload:Stop() | |
1211 | end) | |
1212 | self.Tool.Unequipped:connect(function() | |
1213 | self.Tool.Handle.Fire:Stop() | |
1214 | self.Tool.Handle.Reload:Stop() | |
1215 | end) | |
1216 | self.LaserObj = Instance.new("Part") | |
1217 | self.LaserObj.Name = "Bullet" | |
1218 | self.LaserObj.Anchored = true | |
1219 | self.LaserObj.CanCollide = false | |
1220 | self.LaserObj.Shape = "Block" | |
1221 | self.LaserObj.formFactor = "Custom" | |
1222 | self.LaserObj.Material = Enum.Material.Neon | |
1223 | self.LaserObj.Locked = true | |
1224 | self.LaserObj.TopSurface = 0 | |
1225 | self.LaserObj.BottomSurface = 0 | |
1226 | ||
1227 | local tSparkEffect = Instance.new("Part") | |
1228 | tSparkEffect.Name = "Effect" | |
1229 | tSparkEffect.Anchored = false | |
1230 | tSparkEffect.CanCollide = false | |
1231 | tSparkEffect.Shape = "Block" | |
1232 | tSparkEffect.formFactor = "Custom" | |
1233 | tSparkEffect.Material = Enum.Material.Neon | |
1234 | tSparkEffect.Locked = true | |
1235 | tSparkEffect.TopSurface = 0 | |
1236 | tSparkEffect.BottomSurface = 0 | |
1237 | self.SparkEffect=tSparkEffect | |
1238 | ||
1239 | local tshell = Instance.new('Part') | |
1240 | tshell.Name='effect' | |
1241 | tshell.FormFactor='Custom' | |
1242 | tshell.Size=Vector3.new(1, 0.4, 0.33) | |
1243 | tshell.BrickColor=BrickColor.new('Bright yellow') | |
1244 | local tshellmesh=WaitForChild(script.Parent,'BulletMesh'):Clone() | |
1245 | tshellmesh.Parent=tshell | |
1246 | self.ShellPart = tshell | |
1247 | ||
1248 | self.DownVal.Changed:connect(function() | |
1249 | while self.DownVal.Value and self.check and not self.Reloading do | |
1250 | self.check = false | |
1251 | local humanoid = self.Tool.Parent:FindFirstChild("Humanoid") | |
1252 | local plr1 = game.Players:GetPlayerFromCharacter(self.Tool.Parent) | |
1253 | if humanoid ~= nil and plr1 ~= nil then | |
1254 | if humanoid.Health > 0 then | |
1255 | local spos1 = (self.Tool.Handle.CFrame * self.BarrelPos).p | |
1256 | delay(0, function() self:SendBullet(spos1, self.AimVal.Value, self.Spread, self.SegmentLength, self.Tool.Parent, self.Colors[1], self.GunDamage, self.FadeDelayTime) end) | |
1257 | else | |
1258 | self.check = true | |
1259 | break | |
1260 | end | |
1261 | else | |
1262 | self.check = true | |
1263 | break | |
1264 | end | |
1265 | wait(self.FireRate) | |
1266 | self.check = true | |
1267 | if not self.Automatic then | |
1268 | break | |
1269 | end | |
1270 | end | |
1271 | end) | |
1272 | ||
1273 | self.ReloadingVal.Changed:connect(function() if self.ReloadingVal.Value then self:Reload() end end) | |
1274 | ||
1275 | end | |
1276 | ||
1277 | ||
1278 | ||
1279 | function GunObject:Reload() | |
1280 | self.Reloading = true | |
1281 | self.ReloadingVal.Value = true | |
1282 | if self.Clips ~= nil then | |
1283 | if self.Clips.Value > 0 then | |
1284 | self.Clips.Value = Clips.Value - 1 | |
1285 | else | |
1286 | self.Reloading = false | |
1287 | self.ReloadingVal.Value = false | |
1288 | return | |
1289 | end | |
1290 | end | |
1291 | self.Tool.Handle.Reload:Play() | |
1292 | for i = 1, self.ClipSize do | |
1293 | wait(self.ReloadTime/self.ClipSize) | |
1294 | self.Ammo.Value = i | |
1295 | end | |
1296 | self.Reloading = false | |
1297 | self.Tool.Reloading.Value = false | |
1298 | end | |
1299 | ||
1300 | ||
1301 | ||
1302 | function GunObject:SpawnShell() | |
1303 | local tshell=self.ShellPart:Clone() | |
1304 | tshell.CFrame=self.Handle.CFrame | |
1305 | tshell.Parent=Workspace | |
1306 | game.Debris:AddItem(tshell,2) | |
1307 | end | |
1308 | ||
1309 | function KnockOffHats(tchar) | |
1310 | for _,i in pairs(tchar:GetChildren()) do | |
1311 | if i:IsA('Hat') then | |
1312 | i.Parent=game.Workspace | |
1313 | end | |
1314 | end | |
1315 | end | |
1316 | ||
1317 | function KnockOffTool(tchar) | |
1318 | for _,i in pairs(tchar:GetChildren()) do | |
1319 | if i:IsA('Tool') then | |
1320 | i.Parent=game.Workspace | |
1321 | end | |
1322 | end | |
1323 | end | |
1324 | ||
1325 | function GunObject:SendBullet(boltstart, targetpos, fuzzyness, SegmentLength, ignore, clr, damage, fadedelay) | |
1326 | if self.Ammo.Value <=0 then return end | |
1327 | self.Ammo.Value = self.Ammo.Value - 1 | |
1328 | self:SpawnShell() | |
1329 | self.Fire.Pitch = 1 | |
1330 | self.Fire:Play() | |
1331 | self.Volume = 10 | |
1332 | self.Fire.TimePosition = 0 | |
1333 | self.DoFireAni.Value = not self.DoFireAni.Value | |
1334 | print(self.Fire.Pitch) | |
1335 | local boltdist = self.Range | |
1336 | local clickdist = (boltstart - targetpos).magnitude | |
1337 | local targetpos = targetpos + (Vector3.new(math.random() - .5, math.random() - .5, math.random() - .5) * (clickdist/100) * fuzzyness) | |
1338 | local boltvec = (targetpos - boltstart).unit | |
1339 | local totalsegments = math.ceil(boltdist/SegmentLength) | |
1340 | local lastpos = boltstart | |
1341 | for i = 1, totalsegments do | |
1342 | local newpos = (boltstart + (boltvec * (boltdist * (i/totalsegments)))) | |
1343 | local segvec = (newpos - lastpos).unit | |
1344 | local boltlength = (newpos - lastpos).magnitude | |
1345 | local bolthit, endpos = CastRay(lastpos, segvec, boltlength, ignore, false) | |
1346 | DrawBeam(lastpos, endpos, clr, fadedelay, self.LaserObj) | |
1347 | if bolthit ~= nil then | |
1348 | local h = bolthit.Parent:FindFirstChild("Humanoid") | |
1349 | if h ~= nil then | |
1350 | local plr = game.Players:GetPlayerFromCharacter(self.Tool.Parent) | |
1351 | if plr ~= nil then | |
1352 | local creator = Instance.new("ObjectValue") | |
1353 | creator.Name = "creator" | |
1354 | creator.Value = plr | |
1355 | creator.Parent = h | |
1356 | end | |
1357 | if hit.Parent:FindFirstChild("BlockShot") then | |
1358 | hit.Parent:FindFirstChild("BlockShot"):Fire(newpos) | |
1359 | delay(0, function() self:HitEffect(endpos, BrickColor.new('Bright yellow'),5) end) | |
1360 | else | |
1361 | if(hit.Name=='Head') then | |
1362 | KnockOffHats(hit.Parent) | |
1363 | end | |
1364 | if GoreOn then delay(0,function() self:HitEffect(endpos, BrickColor.new('Bright red'),20) end) end | |
1365 | h:TakeDamage(damage) | |
1366 | end | |
1367 | else | |
1368 | delay(0, function() self:HitEffect(endpos, BrickColor.new('Bright yellow'),5) end) | |
1369 | end | |
1370 | break | |
1371 | end | |
1372 | lastpos = endpos | |
1373 | wait(Rate) | |
1374 | end | |
1375 | ||
1376 | if self.Ammo.Value < 1 then | |
1377 | self:Reload() | |
1378 | end | |
1379 | ||
1380 | end | |
1381 | ||
1382 | ||
1383 | ||
1384 | function GunObject:MakeSpark(pos,tcolor) | |
1385 | local effect=self.SparkEffect:Clone() | |
1386 | effect.BrickColor = tcolor | |
1387 | effect.CFrame = CFrame.new(pos) | |
1388 | effect.Parent = game.Workspace | |
1389 | local effectVel = Instance.new("BodyVelocity") | |
1390 | effectVel.maxForce = Vector3.new(99999, 99999, 99999) | |
1391 | effectVel.velocity = Vector3.new(math.random() * 15 * SigNum(math.random( - 10, 10)), math.random() * 15 * SigNum(math.random( - 10, 10)), math.random() * 15 * SigNum(math.random( - 10, 10))) | |
1392 | effectVel.Parent = effect | |
1393 | effect.Size = Vector3.new(math.abs(effectVel.velocity.x)/30, math.abs(effectVel.velocity.y)/30, math.abs(effectVel.velocity.z)/30) | |
1394 | wait() | |
1395 | effectVel:Destroy() | |
1396 | local effecttime = .5 | |
1397 | game.Debris:AddItem(effect, effecttime * 2) | |
1398 | local startTime = time() | |
1399 | while time() - startTime < effecttime do | |
1400 | if effect ~= nil then | |
1401 | effect.Transparency = (time() - startTime)/effecttime | |
1402 | end | |
1403 | wait() | |
1404 | end | |
1405 | if effect ~= nil then | |
1406 | effect.Parent = nil | |
1407 | end | |
1408 | end | |
1409 | ||
1410 | function GunObject:HitEffect(pos,tcolor,numSparks) | |
1411 | for i = 0, numSparks, 1 do | |
1412 | Spawn(function() self:MakeSpark(pos,tcolor) end) | |
1413 | end | |
1414 | ||
1415 | end | |
1416 | ||
1417 | --[[/Member functions]] | |
1418 | ||
1419 | ||
1420 | --[[Static functions]] | |
1421 | ||
1422 | function Round(number, decimal) | |
1423 | decimal = decimal or 0 | |
1424 | local mult = 10^decimal | |
1425 | return math.floor(number * mult + .5)/mult | |
1426 | end | |
1427 | ||
1428 | function SigNum(num) | |
1429 | if num == 0 then return 1 end | |
1430 | return math.abs(num)/num | |
1431 | end | |
1432 | ||
1433 | --this is a little bad, but shouldn't really be part of the 'class' of the gun | |
1434 | local Intangibles = {shock=1, bolt=1, bullet=1, plasma=1, effect=1, laser=1, handle=1, effects=1, flash=1,} | |
1435 | function CheckIntangible(hitObj) | |
1436 | print(hitObj.Name) | |
1437 | return Intangibles[(string.lower(hitObj.Name))] or hitObj.Transparency == 1 | |
1438 | end | |
1439 | ||
1440 | function CastRay(startpos, vec, length, ignore, delayifhit) | |
1441 | if length > 999 then | |
1442 | length = 999 | |
1443 | end | |
1444 | hit, endpos2 = game.Workspace:FindPartOnRay(Ray.new(startpos, vec * length), ignore) | |
1445 | if hit ~= nil then | |
1446 | if CheckIntangible(hit) then | |
1447 | if delayifhit then | |
1448 | wait() | |
1449 | end | |
1450 | hit, endpos2 = CastRay(endpos2 + (vec * .01), vec, length - ((startpos - endpos2).magnitude), ignore, delayifhit) | |
1451 | end | |
1452 | end | |
1453 | return hit, endpos2 | |
1454 | end | |
1455 | ||
1456 | function DrawBeam(beamstart, beamend, clr, fadedelay, templatePart) | |
1457 | local dis = 2 --(beamstart - beamend).magnitude | |
1458 | local tlaser=templatePart:Clone() | |
1459 | tlaser.BrickColor = clr | |
1460 | tlaser.Size = Vector3.new(.1, .1, dis + .2) | |
1461 | tlaser.CFrame = CFrame.new((beamend+beamstart)/2, beamstart) * CFrame.new(0, 0, - dis/2) | |
1462 | tlaser.Parent = game.Workspace | |
1463 | game.Debris:AddItem(tlaser, fadedelay) | |
1464 | end | |
1465 | ||
1466 | --[[/Static functions]] | |
1467 | ||
1468 | ||
1469 | GunObject:Initialize() | |
1470 | end)) | |
1471 | Script32.Name = "Firescript" | |
1472 | Script32.Parent = Tool0 | |
1473 | table.insert(cors,sandbox(Script32,function() | |
1474 | -- Made by Stickmasterluke | |
1475 | -- edited by fusroblox | |
1476 | local GoreOn=true | |
1477 | function WaitForChild(parent,child) | |
1478 | while not parent:FindFirstChild(child) do print("2waiting for " .. child) wait() end | |
1479 | return parent[child] | |
1480 | end | |
1481 | ||
1482 | local GunObject = { | |
1483 | Tool = script.Parent, | |
1484 | Handle = WaitForChild(script.Parent,'Handle'), | |
1485 | check = true, | |
1486 | ||
1487 | GunDamage = 27, -- Base output damage per shot. | |
1488 | FireRate = .7, -- How often the weapon can fire. | |
1489 | Automatic = false, -- hold down to continue firing | |
1490 | Range = 250, -- Max distance that the weapon can fire. | |
1491 | Spread = 7, -- The bigger the spread, the more inaccurate the shots will be. | |
1492 | ClipSize = 36, -- Shots in a clip | |
1493 | ReloadTime = 0, -- Time it takes to reload the tool. | |
1494 | StartingClips = 10, -- If you want infinit clips, remove the IntValue named "Clips" from the tool. | |
1495 | SegmentLength = 40, -- How long the shot segments are, or the speed of the shot. | |
1496 | FadeDelayTime = 1/30, | |
1497 | ||
1498 | ||
1499 | BarrelPos = CFrame.new(0, 0, - 1.2), -- L, F, U | |
1500 | Rate = 1/30, | |
1501 | --local Colors = {BrickColor.new("Bright red"), BrickColor.new("Really red"), BrickColor.new("Dusty Rose"), BrickColor.new("Medium red")} | |
1502 | Colors = {BrickColor.new("Bright yellow"),BrickColor.new("Mid gray"), BrickColor.new("Medium stone grey"), BrickColor.new("Dark stone grey")}, | |
1503 | FlashColors = {"Medium red", "Dusty Rose", "Bright red", "Really red"}, | |
1504 | ||
1505 | Reloading = false, | |
1506 | Debris = game:GetService("Debris"), | |
1507 | Ammo, | |
1508 | Clips, | |
1509 | LaserObj, | |
1510 | SparkEffect, | |
1511 | ShellPart, | |
1512 | --tool children | |
1513 | DownVal=WaitForChild(script.Parent, 'Down'), | |
1514 | AimVal=WaitForChild(script.Parent, 'Aim'), | |
1515 | ReloadingVal=WaitForChild(script.Parent, 'Reloading'), | |
1516 | DoFireAni = WaitForChild(script.Parent,'DoFireAni'), | |
1517 | ||
1518 | --handlechildren | |
1519 | Fire, | |
1520 | ||
1521 | } | |
1522 | ||
1523 | --[[Member functions]] | |
1524 | ||
1525 | function GunObject:Initialize() | |
1526 | ||
1527 | self.Fire=WaitForChild(self.Handle, 'Fire') | |
1528 | ||
1529 | self.Ammo = self.Tool:FindFirstChild("Ammo") | |
1530 | if self.Ammo ~= nil then | |
1531 | self.Ammo.Value = self.ClipSize | |
1532 | end | |
1533 | self.Clips = self.Tool:FindFirstChild("Clips") | |
1534 | if self.Clips ~= nil then | |
1535 | self.Clips.Value = self.StartingClips | |
1536 | end | |
1537 | self.Tool.Equipped:connect(function() | |
1538 | self.Tool.Handle.Fire:Stop() | |
1539 | self.Tool.Handle.Reload:Stop() | |
1540 | end) | |
1541 | self.Tool.Unequipped:connect(function() | |
1542 | self.Tool.Handle.Fire:Stop() | |
1543 | self.Tool.Handle.Reload:Stop() | |
1544 | end) | |
1545 | self.LaserObj = Instance.new("Part") | |
1546 | self.LaserObj.Name = "Bullet" | |
1547 | self.LaserObj.Anchored = true | |
1548 | self.LaserObj.CanCollide = false | |
1549 | self.LaserObj.Shape = "Block" | |
1550 | self.LaserObj.formFactor = "Custom" | |
1551 | self.LaserObj.Material = Enum.Material.Neon | |
1552 | self.LaserObj.Locked = true | |
1553 | self.LaserObj.TopSurface = 0 | |
1554 | self.LaserObj.BottomSurface = 0 | |
1555 | ||
1556 | local tSparkEffect = Instance.new("Part") | |
1557 | tSparkEffect.Name = "Effect" | |
1558 | tSparkEffect.Anchored = false | |
1559 | tSparkEffect.CanCollide = false | |
1560 | tSparkEffect.Shape = "Block" | |
1561 | tSparkEffect.formFactor = "Custom" | |
1562 | tSparkEffect.Material = Enum.Material.Neon | |
1563 | tSparkEffect.Locked = true | |
1564 | tSparkEffect.TopSurface = 0 | |
1565 | tSparkEffect.BottomSurface = 0 | |
1566 | self.SparkEffect=tSparkEffect | |
1567 | ||
1568 | local tshell = Instance.new('Part') | |
1569 | tshell.Name='effect' | |
1570 | tshell.FormFactor='Custom' | |
1571 | tshell.Size=Vector3.new(1, 0.4, 0.33) | |
1572 | tshell.BrickColor=BrickColor.new('Bright yellow') | |
1573 | local tshellmesh=WaitForChild(script.Parent,'BulletMesh'):Clone() | |
1574 | tshellmesh.Parent=tshell | |
1575 | self.ShellPart = tshell | |
1576 | ||
1577 | self.DownVal.Changed:connect(function() | |
1578 | while self.DownVal.Value and self.check and not self.Reloading do | |
1579 | self.check = false | |
1580 | local humanoid = self.Tool.Parent:FindFirstChild("Humanoid") | |
1581 | local plr1 = game.Players:GetPlayerFromCharacter(self.Tool.Parent) | |
1582 | if humanoid ~= nil and plr1 ~= nil then | |
1583 | if humanoid.Health > 0 then | |
1584 | local spos1 = (self.Tool.Handle.CFrame * self.BarrelPos).p | |
1585 | delay(0, function() self:SendBullet(spos1, self.AimVal.Value, self.Spread, self.SegmentLength, self.Tool.Parent, self.Colors[1], self.GunDamage, self.FadeDelayTime) end) | |
1586 | else | |
1587 | self.check = true | |
1588 | break | |
1589 | end | |
1590 | else | |
1591 | self.check = true | |
1592 | break | |
1593 | end | |
1594 | wait(self.FireRate) | |
1595 | self.check = true | |
1596 | if not self.Automatic then | |
1597 | break | |
1598 | end | |
1599 | end | |
1600 | end) | |
1601 | ||
1602 | self.ReloadingVal.Changed:connect(function() if self.ReloadingVal.Value then self:Reload() end end) | |
1603 | ||
1604 | end | |
1605 | ||
1606 | ||
1607 | ||
1608 | function GunObject:Reload() | |
1609 | self.Reloading = true | |
1610 | self.ReloadingVal.Value = true | |
1611 | if self.Clips ~= nil then | |
1612 | if self.Clips.Value > 0 then | |
1613 | self.Clips.Value = Clips.Value - 1 | |
1614 | else | |
1615 | self.Reloading = false | |
1616 | self.ReloadingVal.Value = false | |
1617 | return | |
1618 | end | |
1619 | end | |
1620 | self.Tool.Handle.Reload:Play() | |
1621 | for i = 1, self.ClipSize do | |
1622 | wait(self.ReloadTime/self.ClipSize) | |
1623 | self.Ammo.Value = i | |
1624 | end | |
1625 | self.Reloading = false | |
1626 | self.Tool.Reloading.Value = false | |
1627 | end | |
1628 | ||
1629 | ||
1630 | ||
1631 | function GunObject:SpawnShell() | |
1632 | local tshell=self.ShellPart:Clone() | |
1633 | tshell.CFrame=self.Handle.CFrame | |
1634 | tshell.Parent=Workspace | |
1635 | game.Debris:AddItem(tshell,2) | |
1636 | end | |
1637 | ||
1638 | function KnockOffHats(tchar) | |
1639 | for _,i in pairs(tchar:GetChildren()) do | |
1640 | if i:IsA('Hat') then | |
1641 | i.Parent=game.Workspace | |
1642 | end | |
1643 | end | |
1644 | end | |
1645 | ||
1646 | function KnockOffTool(tchar) | |
1647 | for _,i in pairs(tchar:GetChildren()) do | |
1648 | if i:IsA('Tool') then | |
1649 | i.Parent=game.Workspace | |
1650 | end | |
1651 | end | |
1652 | end | |
1653 | ||
1654 | function GunObject:SendBullet(boltstart, targetpos, fuzzyness, SegmentLength, ignore, clr, damage, fadedelay) | |
1655 | if self.Ammo.Value <=0 then return end | |
1656 | self.Ammo.Value = self.Ammo.Value - 1 | |
1657 | self:SpawnShell() | |
1658 | self.Fire.Pitch = 1 | |
1659 | self.Fire:Play() | |
1660 | self.Volume = 10 | |
1661 | self.Fire.TimePosition = 0 | |
1662 | self.DoFireAni.Value = not self.DoFireAni.Value | |
1663 | print(self.Fire.Pitch) | |
1664 | local boltdist = self.Range | |
1665 | local clickdist = (boltstart - targetpos).magnitude | |
1666 | local targetpos = targetpos + (Vector3.new(math.random() - .5, math.random() - .5, math.random() - .5) * (clickdist/100) * fuzzyness) | |
1667 | local boltvec = (targetpos - boltstart).unit | |
1668 | local totalsegments = math.ceil(boltdist/SegmentLength) | |
1669 | local lastpos = boltstart | |
1670 | for i = 1, totalsegments do | |
1671 | local newpos = (boltstart + (boltvec * (boltdist * (i/totalsegments)))) | |
1672 | local segvec = (newpos - lastpos).unit | |
1673 | local boltlength = (newpos - lastpos).magnitude | |
1674 | local bolthit, endpos = CastRay(lastpos, segvec, boltlength, ignore, false) | |
1675 | DrawBeam(lastpos, endpos, clr, fadedelay, self.LaserObj) | |
1676 | if bolthit ~= nil then | |
1677 | local h = bolthit.Parent:FindFirstChild("Humanoid") | |
1678 | if h ~= nil then | |
1679 | local plr = game.Players:GetPlayerFromCharacter(self.Tool.Parent) | |
1680 | if plr ~= nil then | |
1681 | local creator = Instance.new("ObjectValue") | |
1682 | creator.Name = "creator" | |
1683 | creator.Value = plr | |
1684 | creator.Parent = h | |
1685 | end | |
1686 | if hit.Parent:FindFirstChild("BlockShot") then | |
1687 | hit.Parent:FindFirstChild("BlockShot"):Fire(newpos) | |
1688 | delay(0, function() self:HitEffect(endpos, BrickColor.new('Bright yellow'),5) end) | |
1689 | else | |
1690 | if(hit.Name=='Head') then | |
1691 | KnockOffHats(hit.Parent) | |
1692 | end | |
1693 | if GoreOn then delay(0,function() self:HitEffect(endpos, BrickColor.new('Bright red'),20) end) end | |
1694 | h:TakeDamage(damage) | |
1695 | end | |
1696 | else | |
1697 | delay(0, function() self:HitEffect(endpos, BrickColor.new('Bright yellow'),5) end) | |
1698 | end | |
1699 | break | |
1700 | end | |
1701 | lastpos = endpos | |
1702 | wait(Rate) | |
1703 | end | |
1704 | ||
1705 | if self.Ammo.Value < 1 then | |
1706 | self:Reload() | |
1707 | end | |
1708 | ||
1709 | end | |
1710 | ||
1711 | ||
1712 | ||
1713 | function GunObject:MakeSpark(pos,tcolor) | |
1714 | local effect=self.SparkEffect:Clone() | |
1715 | effect.BrickColor = tcolor | |
1716 | effect.CFrame = CFrame.new(pos) | |
1717 | effect.Parent = game.Workspace | |
1718 | local effectVel = Instance.new("BodyVelocity") | |
1719 | effectVel.maxForce = Vector3.new(99999, 99999, 99999) | |
1720 | effectVel.velocity = Vector3.new(math.random() * 15 * SigNum(math.random( - 10, 10)), math.random() * 15 * SigNum(math.random( - 10, 10)), math.random() * 15 * SigNum(math.random( - 10, 10))) | |
1721 | effectVel.Parent = effect | |
1722 | effect.Size = Vector3.new(math.abs(effectVel.velocity.x)/30, math.abs(effectVel.velocity.y)/30, math.abs(effectVel.velocity.z)/30) | |
1723 | wait() | |
1724 | effectVel:Destroy() | |
1725 | local effecttime = .5 | |
1726 | game.Debris:AddItem(effect, effecttime * 2) | |
1727 | local startTime = time() | |
1728 | while time() - startTime < effecttime do | |
1729 | if effect ~= nil then | |
1730 | effect.Transparency = (time() - startTime)/effecttime | |
1731 | end | |
1732 | wait() | |
1733 | end | |
1734 | if effect ~= nil then | |
1735 | effect.Parent = nil | |
1736 | end | |
1737 | end | |
1738 | ||
1739 | function GunObject:HitEffect(pos,tcolor,numSparks) | |
1740 | for i = 0, numSparks, 1 do | |
1741 | Spawn(function() self:MakeSpark(pos,tcolor) end) | |
1742 | end | |
1743 | ||
1744 | end | |
1745 | ||
1746 | --[[/Member functions]] | |
1747 | ||
1748 | ||
1749 | --[[Static functions]] | |
1750 | ||
1751 | function Round(number, decimal) | |
1752 | decimal = decimal or 0 | |
1753 | local mult = 10^decimal | |
1754 | return math.floor(number * mult + .5)/mult | |
1755 | end | |
1756 | ||
1757 | function SigNum(num) | |
1758 | if num == 0 then return 1 end | |
1759 | return math.abs(num)/num | |
1760 | end | |
1761 | ||
1762 | --this is a little bad, but shouldn't really be part of the 'class' of the gun | |
1763 | local Intangibles = {shock=1, bolt=1, bullet=1, plasma=1, effect=1, laser=1, handle=1, effects=1, flash=1,} | |
1764 | function CheckIntangible(hitObj) | |
1765 | print(hitObj.Name) | |
1766 | return Intangibles[(string.lower(hitObj.Name))] or hitObj.Transparency == 1 | |
1767 | end | |
1768 | ||
1769 | function CastRay(startpos, vec, length, ignore, delayifhit) | |
1770 | if length > 999 then | |
1771 | length = 999 | |
1772 | end | |
1773 | hit, endpos2 = game.Workspace:FindPartOnRay(Ray.new(startpos, vec * length), ignore) | |
1774 | if hit ~= nil then | |
1775 | if CheckIntangible(hit) then | |
1776 | if delayifhit then | |
1777 | wait() | |
1778 | end | |
1779 | hit, endpos2 = CastRay(endpos2 + (vec * .01), vec, length - ((startpos - endpos2).magnitude), ignore, delayifhit) | |
1780 | end | |
1781 | end | |
1782 | return hit, endpos2 | |
1783 | end | |
1784 | ||
1785 | function DrawBeam(beamstart, beamend, clr, fadedelay, templatePart) | |
1786 | local dis = 2 --(beamstart - beamend).magnitude | |
1787 | local tlaser=templatePart:Clone() | |
1788 | tlaser.BrickColor = clr | |
1789 | tlaser.Size = Vector3.new(.1, .1, dis + .2) | |
1790 | tlaser.CFrame = CFrame.new((beamend+beamstart)/2, beamstart) * CFrame.new(0, 0, - dis/2) | |
1791 | tlaser.Parent = game.Workspace | |
1792 | game.Debris:AddItem(tlaser, fadedelay) | |
1793 | end | |
1794 | ||
1795 | --[[/Static functions]] | |
1796 | ||
1797 | ||
1798 | GunObject:Initialize() | |
1799 | end)) | |
1800 | Script33.Name = "Firescript" | |
1801 | Script33.Parent = Tool0 | |
1802 | table.insert(cors,sandbox(Script33,function() | |
1803 | -- Made by Stickmasterluke | |
1804 | -- edited by fusroblox | |
1805 | local GoreOn=true | |
1806 | function WaitForChild(parent,child) | |
1807 | while not parent:FindFirstChild(child) do print("2waiting for " .. child) wait() end | |
1808 | return parent[child] | |
1809 | end | |
1810 | ||
1811 | local GunObject = { | |
1812 | Tool = script.Parent, | |
1813 | Handle = WaitForChild(script.Parent,'Handle'), | |
1814 | check = true, | |
1815 | ||
1816 | GunDamage = 27, -- Base output damage per shot. | |
1817 | FireRate = .7, -- How often the weapon can fire. | |
1818 | Automatic = false, -- hold down to continue firing | |
1819 | Range = 250, -- Max distance that the weapon can fire. | |
1820 | Spread = 7, -- The bigger the spread, the more inaccurate the shots will be. | |
1821 | ClipSize = 36, -- Shots in a clip | |
1822 | ReloadTime = 0, -- Time it takes to reload the tool. | |
1823 | StartingClips = 10, -- If you want infinit clips, remove the IntValue named "Clips" from the tool. | |
1824 | SegmentLength = 40, -- How long the shot segments are, or the speed of the shot. | |
1825 | FadeDelayTime = 1/30, | |
1826 | ||
1827 | ||
1828 | BarrelPos = CFrame.new(0, 0, - 1.2), -- L, F, U | |
1829 | Rate = 1/30, | |
1830 | --local Colors = {BrickColor.new("Bright red"), BrickColor.new("Really red"), BrickColor.new("Dusty Rose"), BrickColor.new("Medium red")} | |
1831 | Colors = {BrickColor.new("Bright yellow"),BrickColor.new("Mid gray"), BrickColor.new("Medium stone grey"), BrickColor.new("Dark stone grey")}, | |
1832 | FlashColors = {"Medium red", "Dusty Rose", "Bright red", "Really red"}, | |
1833 | ||
1834 | Reloading = false, | |
1835 | Debris = game:GetService("Debris"), | |
1836 | Ammo, | |
1837 | Clips, | |
1838 | LaserObj, | |
1839 | SparkEffect, | |
1840 | ShellPart, | |
1841 | --tool children | |
1842 | DownVal=WaitForChild(script.Parent, 'Down'), | |
1843 | AimVal=WaitForChild(script.Parent, 'Aim'), | |
1844 | ReloadingVal=WaitForChild(script.Parent, 'Reloading'), | |
1845 | DoFireAni = WaitForChild(script.Parent,'DoFireAni'), | |
1846 | ||
1847 | --handlechildren | |
1848 | Fire, | |
1849 | ||
1850 | } | |
1851 | ||
1852 | --[[Member functions]] | |
1853 | ||
1854 | function GunObject:Initialize() | |
1855 | ||
1856 | self.Fire=WaitForChild(self.Handle, 'Fire') | |
1857 | ||
1858 | self.Ammo = self.Tool:FindFirstChild("Ammo") | |
1859 | if self.Ammo ~= nil then | |
1860 | self.Ammo.Value = self.ClipSize | |
1861 | end | |
1862 | self.Clips = self.Tool:FindFirstChild("Clips") | |
1863 | if self.Clips ~= nil then | |
1864 | self.Clips.Value = self.StartingClips | |
1865 | end | |
1866 | self.Tool.Equipped:connect(function() | |
1867 | self.Tool.Handle.Fire:Stop() | |
1868 | self.Tool.Handle.Reload:Stop() | |
1869 | end) | |
1870 | self.Tool.Unequipped:connect(function() | |
1871 | self.Tool.Handle.Fire:Stop() | |
1872 | self.Tool.Handle.Reload:Stop() | |
1873 | end) | |
1874 | self.LaserObj = Instance.new("Part") | |
1875 | self.LaserObj.Name = "Bullet" | |
1876 | self.LaserObj.Anchored = true | |
1877 | self.LaserObj.CanCollide = false | |
1878 | self.LaserObj.Shape = "Block" | |
1879 | self.LaserObj.formFactor = "Custom" | |
1880 | self.LaserObj.Material = Enum.Material.Neon | |
1881 | self.LaserObj.Locked = true | |
1882 | self.LaserObj.TopSurface = 0 | |
1883 | self.LaserObj.BottomSurface = 0 | |
1884 | ||
1885 | local tSparkEffect = Instance.new("Part") | |
1886 | tSparkEffect.Name = "Effect" | |
1887 | tSparkEffect.Anchored = false | |
1888 | tSparkEffect.CanCollide = false | |
1889 | tSparkEffect.Shape = "Block" | |
1890 | tSparkEffect.formFactor = "Custom" | |
1891 | tSparkEffect.Material = Enum.Material.Neon | |
1892 | tSparkEffect.Locked = true | |
1893 | tSparkEffect.TopSurface = 0 | |
1894 | tSparkEffect.BottomSurface = 0 | |
1895 | self.SparkEffect=tSparkEffect | |
1896 | ||
1897 | local tshell = Instance.new('Part') | |
1898 | tshell.Name='effect' | |
1899 | tshell.FormFactor='Custom' | |
1900 | tshell.Size=Vector3.new(1, 0.4, 0.33) | |
1901 | tshell.BrickColor=BrickColor.new('Bright yellow') | |
1902 | local tshellmesh=WaitForChild(script.Parent,'BulletMesh'):Clone() | |
1903 | tshellmesh.Parent=tshell | |
1904 | self.ShellPart = tshell | |
1905 | ||
1906 | self.DownVal.Changed:connect(function() | |
1907 | while self.DownVal.Value and self.check and not self.Reloading do | |
1908 | self.check = false | |
1909 | local humanoid = self.Tool.Parent:FindFirstChild("Humanoid") | |
1910 | local plr1 = game.Players:GetPlayerFromCharacter(self.Tool.Parent) | |
1911 | if humanoid ~= nil and plr1 ~= nil then | |
1912 | if humanoid.Health > 0 then | |
1913 | local spos1 = (self.Tool.Handle.CFrame * self.BarrelPos).p | |
1914 | delay(0, function() self:SendBullet(spos1, self.AimVal.Value, self.Spread, self.SegmentLength, self.Tool.Parent, self.Colors[1], self.GunDamage, self.FadeDelayTime) end) | |
1915 | else | |
1916 | self.check = true | |
1917 | break | |
1918 | end | |
1919 | else | |
1920 | self.check = true | |
1921 | break | |
1922 | end | |
1923 | wait(self.FireRate) | |
1924 | self.check = true | |
1925 | if not self.Automatic then | |
1926 | break | |
1927 | end | |
1928 | end | |
1929 | end) | |
1930 | ||
1931 | self.ReloadingVal.Changed:connect(function() if self.ReloadingVal.Value then self:Reload() end end) | |
1932 | ||
1933 | end | |
1934 | ||
1935 | ||
1936 | ||
1937 | function GunObject:Reload() | |
1938 | self.Reloading = true | |
1939 | self.ReloadingVal.Value = true | |
1940 | if self.Clips ~= nil then | |
1941 | if self.Clips.Value > 0 then | |
1942 | self.Clips.Value = Clips.Value - 1 | |
1943 | else | |
1944 | self.Reloading = false | |
1945 | self.ReloadingVal.Value = false | |
1946 | return | |
1947 | end | |
1948 | end | |
1949 | self.Tool.Handle.Reload:Play() | |
1950 | for i = 1, self.ClipSize do | |
1951 | wait(self.ReloadTime/self.ClipSize) | |
1952 | self.Ammo.Value = i | |
1953 | end | |
1954 | self.Reloading = false | |
1955 | self.Tool.Reloading.Value = false | |
1956 | end | |
1957 | ||
1958 | ||
1959 | ||
1960 | function GunObject:SpawnShell() | |
1961 | local tshell=self.ShellPart:Clone() | |
1962 | tshell.CFrame=self.Handle.CFrame | |
1963 | tshell.Parent=Workspace | |
1964 | game.Debris:AddItem(tshell,2) | |
1965 | end | |
1966 | ||
1967 | function KnockOffHats(tchar) | |
1968 | for _,i in pairs(tchar:GetChildren()) do | |
1969 | if i:IsA('Hat') then | |
1970 | i.Parent=game.Workspace | |
1971 | end | |
1972 | end | |
1973 | end | |
1974 | ||
1975 | function KnockOffTool(tchar) | |
1976 | for _,i in pairs(tchar:GetChildren()) do | |
1977 | if i:IsA('Tool') then | |
1978 | i.Parent=game.Workspace | |
1979 | end | |
1980 | end | |
1981 | end | |
1982 | ||
1983 | function GunObject:SendBullet(boltstart, targetpos, fuzzyness, SegmentLength, ignore, clr, damage, fadedelay) | |
1984 | if self.Ammo.Value <=0 then return end | |
1985 | self.Ammo.Value = self.Ammo.Value - 1 | |
1986 | self:SpawnShell() | |
1987 | self.Fire.Pitch = 1 | |
1988 | self.Fire:Play() | |
1989 | self.Volume = 10 | |
1990 | self.Fire.TimePosition = 0 | |
1991 | self.DoFireAni.Value = not self.DoFireAni.Value | |
1992 | print(self.Fire.Pitch) | |
1993 | local boltdist = self.Range | |
1994 | local clickdist = (boltstart - targetpos).magnitude | |
1995 | local targetpos = targetpos + (Vector3.new(math.random() - .5, math.random() - .5, math.random() - .5) * (clickdist/100) * fuzzyness) | |
1996 | local boltvec = (targetpos - boltstart).unit | |
1997 | local totalsegments = math.ceil(boltdist/SegmentLength) | |
1998 | local lastpos = boltstart | |
1999 | for i = 1, totalsegments do | |
2000 | local newpos = (boltstart + (boltvec * (boltdist * (i/totalsegments)))) | |
2001 | local segvec = (newpos - lastpos).unit | |
2002 | local boltlength = (newpos - lastpos).magnitude | |
2003 | local bolthit, endpos = CastRay(lastpos, segvec, boltlength, ignore, false) | |
2004 | DrawBeam(lastpos, endpos, clr, fadedelay, self.LaserObj) | |
2005 | if bolthit ~= nil then | |
2006 | local h = bolthit.Parent:FindFirstChild("Humanoid") | |
2007 | if h ~= nil then | |
2008 | local plr = game.Players:GetPlayerFromCharacter(self.Tool.Parent) | |
2009 | if plr ~= nil then | |
2010 | local creator = Instance.new("ObjectValue") | |
2011 | creator.Name = "creator" | |
2012 | creator.Value = plr | |
2013 | creator.Parent = h | |
2014 | end | |
2015 | if hit.Parent:FindFirstChild("BlockShot") then | |
2016 | hit.Parent:FindFirstChild("BlockShot"):Fire(newpos) | |
2017 | delay(0, function() self:HitEffect(endpos, BrickColor.new('Bright yellow'),5) end) | |
2018 | else | |
2019 | if(hit.Name=='Head') then | |
2020 | KnockOffHats(hit.Parent) | |
2021 | end | |
2022 | if GoreOn then delay(0,function() self:HitEffect(endpos, BrickColor.new('Bright red'),20) end) end | |
2023 | h:TakeDamage(damage) | |
2024 | end | |
2025 | else | |
2026 | delay(0, function() self:HitEffect(endpos, BrickColor.new('Bright yellow'),5) end) | |
2027 | end | |
2028 | break | |
2029 | end | |
2030 | lastpos = endpos | |
2031 | wait(Rate) | |
2032 | end | |
2033 | ||
2034 | if self.Ammo.Value < 1 then | |
2035 | self:Reload() | |
2036 | end | |
2037 | ||
2038 | end | |
2039 | ||
2040 | ||
2041 | ||
2042 | function GunObject:MakeSpark(pos,tcolor) | |
2043 | local effect=self.SparkEffect:Clone() | |
2044 | effect.BrickColor = tcolor | |
2045 | effect.CFrame = CFrame.new(pos) | |
2046 | effect.Parent = game.Workspace | |
2047 | local effectVel = Instance.new("BodyVelocity") | |
2048 | effectVel.maxForce = Vector3.new(99999, 99999, 99999) | |
2049 | effectVel.velocity = Vector3.new(math.random() * 15 * SigNum(math.random( - 10, 10)), math.random() * 15 * SigNum(math.random( - 10, 10)), math.random() * 15 * SigNum(math.random( - 10, 10))) | |
2050 | effectVel.Parent = effect | |
2051 | effect.Size = Vector3.new(math.abs(effectVel.velocity.x)/30, math.abs(effectVel.velocity.y)/30, math.abs(effectVel.velocity.z)/30) | |
2052 | wait() | |
2053 | effectVel:Destroy() | |
2054 | local effecttime = .5 | |
2055 | game.Debris:AddItem(effect, effecttime * 2) | |
2056 | local startTime = time() | |
2057 | while time() - startTime < effecttime do | |
2058 | if effect ~= nil then | |
2059 | effect.Transparency = (time() - startTime)/effecttime | |
2060 | end | |
2061 | wait() | |
2062 | end | |
2063 | if effect ~= nil then | |
2064 | effect.Parent = nil | |
2065 | end | |
2066 | end | |
2067 | ||
2068 | function GunObject:HitEffect(pos,tcolor,numSparks) | |
2069 | for i = 0, numSparks, 1 do | |
2070 | Spawn(function() self:MakeSpark(pos,tcolor) end) | |
2071 | end | |
2072 | ||
2073 | end | |
2074 | ||
2075 | --[[/Member functions]] | |
2076 | ||
2077 | ||
2078 | --[[Static functions]] | |
2079 | ||
2080 | function Round(number, decimal) | |
2081 | decimal = decimal or 0 | |
2082 | local mult = 10^decimal | |
2083 | return math.floor(number * mult + .5)/mult | |
2084 | end | |
2085 | ||
2086 | function SigNum(num) | |
2087 | if num == 0 then return 1 end | |
2088 | return math.abs(num)/num | |
2089 | end | |
2090 | ||
2091 | --this is a little bad, but shouldn't really be part of the 'class' of the gun | |
2092 | local Intangibles = {shock=1, bolt=1, bullet=1, plasma=1, effect=1, laser=1, handle=1, effects=1, flash=1,} | |
2093 | function CheckIntangible(hitObj) | |
2094 | print(hitObj.Name) | |
2095 | return Intangibles[(string.lower(hitObj.Name))] or hitObj.Transparency == 1 | |
2096 | end | |
2097 | ||
2098 | function CastRay(startpos, vec, length, ignore, delayifhit) | |
2099 | if length > 999 then | |
2100 | length = 999 | |
2101 | end | |
2102 | hit, endpos2 = game.Workspace:FindPartOnRay(Ray.new(startpos, vec * length), ignore) | |
2103 | if hit ~= nil then | |
2104 | if CheckIntangible(hit) then | |
2105 | if delayifhit then | |
2106 | wait() | |
2107 | end | |
2108 | hit, endpos2 = CastRay(endpos2 + (vec * .01), vec, length - ((startpos - endpos2).magnitude), ignore, delayifhit) | |
2109 | end | |
2110 | end | |
2111 | return hit, endpos2 | |
2112 | end | |
2113 | ||
2114 | function DrawBeam(beamstart, beamend, clr, fadedelay, templatePart) | |
2115 | local dis = 2 --(beamstart - beamend).magnitude | |
2116 | local tlaser=templatePart:Clone() | |
2117 | tlaser.BrickColor = clr | |
2118 | tlaser.Size = Vector3.new(.1, .1, dis + .2) | |
2119 | tlaser.CFrame = CFrame.new((beamend+beamstart)/2, beamstart) * CFrame.new(0, 0, - dis/2) | |
2120 | tlaser.Parent = game.Workspace | |
2121 | game.Debris:AddItem(tlaser, fadedelay) | |
2122 | end | |
2123 | ||
2124 | --[[/Static functions]] | |
2125 | ||
2126 | ||
2127 | GunObject:Initialize() | |
2128 | end)) | |
2129 | Script34.Name = "Firescript" | |
2130 | Script34.Parent = Tool0 | |
2131 | table.insert(cors,sandbox(Script34,function() | |
2132 | -- Made by Stickmasterluke | |
2133 | -- edited by fusroblox | |
2134 | local GoreOn=true | |
2135 | function WaitForChild(parent,child) | |
2136 | while not parent:FindFirstChild(child) do print("2waiting for " .. child) wait() end | |
2137 | return parent[child] | |
2138 | end | |
2139 | ||
2140 | local GunObject = { | |
2141 | Tool = script.Parent, | |
2142 | Handle = WaitForChild(script.Parent,'Handle'), | |
2143 | check = true, | |
2144 | ||
2145 | GunDamage = 27, -- Base output damage per shot. | |
2146 | FireRate = .7, -- How often the weapon can fire. | |
2147 | Automatic = false, -- hold down to continue firing | |
2148 | Range = 250, -- Max distance that the weapon can fire. | |
2149 | Spread = 7, -- The bigger the spread, the more inaccurate the shots will be. | |
2150 | ClipSize = 36, -- Shots in a clip | |
2151 | ReloadTime = 0, -- Time it takes to reload the tool. | |
2152 | StartingClips = 10, -- If you want infinit clips, remove the IntValue named "Clips" from the tool. | |
2153 | SegmentLength = 40, -- How long the shot segments are, or the speed of the shot. | |
2154 | FadeDelayTime = 1/30, | |
2155 | ||
2156 | ||
2157 | BarrelPos = CFrame.new(0, 0, - 1.2), -- L, F, U | |
2158 | Rate = 1/30, | |
2159 | --local Colors = {BrickColor.new("Bright red"), BrickColor.new("Really red"), BrickColor.new("Dusty Rose"), BrickColor.new("Medium red")} | |
2160 | Colors = {BrickColor.new("Bright yellow"),BrickColor.new("Mid gray"), BrickColor.new("Medium stone grey"), BrickColor.new("Dark stone grey")}, | |
2161 | FlashColors = {"Medium red", "Dusty Rose", "Bright red", "Really red"}, | |
2162 | ||
2163 | Reloading = false, | |
2164 | Debris = game:GetService("Debris"), | |
2165 | Ammo, | |
2166 | Clips, | |
2167 | LaserObj, | |
2168 | SparkEffect, | |
2169 | ShellPart, | |
2170 | --tool children | |
2171 | DownVal=WaitForChild(script.Parent, 'Down'), | |
2172 | AimVal=WaitForChild(script.Parent, 'Aim'), | |
2173 | ReloadingVal=WaitForChild(script.Parent, 'Reloading'), | |
2174 | DoFireAni = WaitForChild(script.Parent,'DoFireAni'), | |
2175 | ||
2176 | --handlechildren | |
2177 | Fire, | |
2178 | ||
2179 | } | |
2180 | ||
2181 | --[[Member functions]] | |
2182 | ||
2183 | function GunObject:Initialize() | |
2184 | ||
2185 | self.Fire=WaitForChild(self.Handle, 'Fire') | |
2186 | ||
2187 | self.Ammo = self.Tool:FindFirstChild("Ammo") | |
2188 | if self.Ammo ~= nil then | |
2189 | self.Ammo.Value = self.ClipSize | |
2190 | end | |
2191 | self.Clips = self.Tool:FindFirstChild("Clips") | |
2192 | if self.Clips ~= nil then | |
2193 | self.Clips.Value = self.StartingClips | |
2194 | end | |
2195 | self.Tool.Equipped:connect(function() | |
2196 | self.Tool.Handle.Fire:Stop() | |
2197 | self.Tool.Handle.Reload:Stop() | |
2198 | end) | |
2199 | self.Tool.Unequipped:connect(function() | |
2200 | self.Tool.Handle.Fire:Stop() | |
2201 | self.Tool.Handle.Reload:Stop() | |
2202 | end) | |
2203 | self.LaserObj = Instance.new("Part") | |
2204 | self.LaserObj.Name = "Bullet" | |
2205 | self.LaserObj.Anchored = true | |
2206 | self.LaserObj.CanCollide = false | |
2207 | self.LaserObj.Shape = "Block" | |
2208 | self.LaserObj.formFactor = "Custom" | |
2209 | self.LaserObj.Material = Enum.Material.Neon | |
2210 | self.LaserObj.Locked = true | |
2211 | self.LaserObj.TopSurface = 0 | |
2212 | self.LaserObj.BottomSurface = 0 | |
2213 | ||
2214 | local tSparkEffect = Instance.new("Part") | |
2215 | tSparkEffect.Name = "Effect" | |
2216 | tSparkEffect.Anchored = false | |
2217 | tSparkEffect.CanCollide = false | |
2218 | tSparkEffect.Shape = "Block" | |
2219 | tSparkEffect.formFactor = "Custom" | |
2220 | tSparkEffect.Material = Enum.Material.Neon | |
2221 | tSparkEffect.Locked = true | |
2222 | tSparkEffect.TopSurface = 0 | |
2223 | tSparkEffect.BottomSurface = 0 | |
2224 | self.SparkEffect=tSparkEffect | |
2225 | ||
2226 | local tshell = Instance.new('Part') | |
2227 | tshell.Name='effect' | |
2228 | tshell.FormFactor='Custom' | |
2229 | tshell.Size=Vector3.new(1, 0.4, 0.33) | |
2230 | tshell.BrickColor=BrickColor.new('Bright yellow') | |
2231 | local tshellmesh=WaitForChild(script.Parent,'BulletMesh'):Clone() | |
2232 | tshellmesh.Parent=tshell | |
2233 | self.ShellPart = tshell | |
2234 | ||
2235 | self.DownVal.Changed:connect(function() | |
2236 | while self.DownVal.Value and self.check and not self.Reloading do | |
2237 | self.check = false | |
2238 | local humanoid = self.Tool.Parent:FindFirstChild("Humanoid") | |
2239 | local plr1 = game.Players:GetPlayerFromCharacter(self.Tool.Parent) | |
2240 | if humanoid ~= nil and plr1 ~= nil then | |
2241 | if humanoid.Health > 0 then | |
2242 | local spos1 = (self.Tool.Handle.CFrame * self.BarrelPos).p | |
2243 | delay(0, function() self:SendBullet(spos1, self.AimVal.Value, self.Spread, self.SegmentLength, self.Tool.Parent, self.Colors[1], self.GunDamage, self.FadeDelayTime) end) | |
2244 | else | |
2245 | self.check = true | |
2246 | break | |
2247 | end | |
2248 | else | |
2249 | self.check = true | |
2250 | break | |
2251 | end | |
2252 | wait(self.FireRate) | |
2253 | self.check = true | |
2254 | if not self.Automatic then | |
2255 | break | |
2256 | end | |
2257 | end | |
2258 | end) | |
2259 | ||
2260 | self.ReloadingVal.Changed:connect(function() if self.ReloadingVal.Value then self:Reload() end end) | |
2261 | ||
2262 | end | |
2263 | ||
2264 | ||
2265 | ||
2266 | function GunObject:Reload() | |
2267 | self.Reloading = true | |
2268 | self.ReloadingVal.Value = true | |
2269 | if self.Clips ~= nil then | |
2270 | if self.Clips.Value > 0 then | |
2271 | self.Clips.Value = Clips.Value - 1 | |
2272 | else | |
2273 | self.Reloading = false | |
2274 | self.ReloadingVal.Value = false | |
2275 | return | |
2276 | end | |
2277 | end | |
2278 | self.Tool.Handle.Reload:Play() | |
2279 | for i = 1, self.ClipSize do | |
2280 | wait(self.ReloadTime/self.ClipSize) | |
2281 | self.Ammo.Value = i | |
2282 | end | |
2283 | self.Reloading = false | |
2284 | self.Tool.Reloading.Value = false | |
2285 | end | |
2286 | ||
2287 | ||
2288 | ||
2289 | function GunObject:SpawnShell() | |
2290 | local tshell=self.ShellPart:Clone() | |
2291 | tshell.CFrame=self.Handle.CFrame | |
2292 | tshell.Parent=Workspace | |
2293 | game.Debris:AddItem(tshell,2) | |
2294 | end | |
2295 | ||
2296 | function KnockOffHats(tchar) | |
2297 | for _,i in pairs(tchar:GetChildren()) do | |
2298 | if i:IsA('Hat') then | |
2299 | i.Parent=game.Workspace | |
2300 | end | |
2301 | end | |
2302 | end | |
2303 | ||
2304 | function KnockOffTool(tchar) | |
2305 | for _,i in pairs(tchar:GetChildren()) do | |
2306 | if i:IsA('Tool') then | |
2307 | i.Parent=game.Workspace | |
2308 | end | |
2309 | end | |
2310 | end | |
2311 | ||
2312 | function GunObject:SendBullet(boltstart, targetpos, fuzzyness, SegmentLength, ignore, clr, damage, fadedelay) | |
2313 | if self.Ammo.Value <=0 then return end | |
2314 | self.Ammo.Value = self.Ammo.Value - 1 | |
2315 | self:SpawnShell() | |
2316 | self.Fire.Pitch = 1 | |
2317 | self.Fire:Play() | |
2318 | self.Volume = 10 | |
2319 | self.Fire.TimePosition = 0 | |
2320 | self.DoFireAni.Value = not self.DoFireAni.Value | |
2321 | print(self.Fire.Pitch) | |
2322 | local boltdist = self.Range | |
2323 | local clickdist = (boltstart - targetpos).magnitude | |
2324 | local targetpos = targetpos + (Vector3.new(math.random() - .5, math.random() - .5, math.random() - .5) * (clickdist/100) * fuzzyness) | |
2325 | local boltvec = (targetpos - boltstart).unit | |
2326 | local totalsegments = math.ceil(boltdist/SegmentLength) | |
2327 | local lastpos = boltstart | |
2328 | for i = 1, totalsegments do | |
2329 | local newpos = (boltstart + (boltvec * (boltdist * (i/totalsegments)))) | |
2330 | local segvec = (newpos - lastpos).unit | |
2331 | local boltlength = (newpos - lastpos).magnitude | |
2332 | local bolthit, endpos = CastRay(lastpos, segvec, boltlength, ignore, false) | |
2333 | DrawBeam(lastpos, endpos, clr, fadedelay, self.LaserObj) | |
2334 | if bolthit ~= nil then | |
2335 | local h = bolthit.Parent:FindFirstChild("Humanoid") | |
2336 | if h ~= nil then | |
2337 | local plr = game.Players:GetPlayerFromCharacter(self.Tool.Parent) | |
2338 | if plr ~= nil then | |
2339 | local creator = Instance.new("ObjectValue") | |
2340 | creator.Name = "creator" | |
2341 | creator.Value = plr | |
2342 | creator.Parent = h | |
2343 | end | |
2344 | if hit.Parent:FindFirstChild("BlockShot") then | |
2345 | hit.Parent:FindFirstChild("BlockShot"):Fire(newpos) | |
2346 | delay(0, function() self:HitEffect(endpos, BrickColor.new('Bright yellow'),5) end) | |
2347 | else | |
2348 | if(hit.Name=='Head') then | |
2349 | KnockOffHats(hit.Parent) | |
2350 | end | |
2351 | if GoreOn then delay(0,function() self:HitEffect(endpos, BrickColor.new('Bright red'),20) end) end | |
2352 | h:TakeDamage(damage) | |
2353 | end | |
2354 | else | |
2355 | delay(0, function() self:HitEffect(endpos, BrickColor.new('Bright yellow'),5) end) | |
2356 | end | |
2357 | break | |
2358 | end | |
2359 | lastpos = endpos | |
2360 | wait(Rate) | |
2361 | end | |
2362 | ||
2363 | if self.Ammo.Value < 1 then | |
2364 | self:Reload() | |
2365 | end | |
2366 | ||
2367 | end | |
2368 | ||
2369 | ||
2370 | ||
2371 | function GunObject:MakeSpark(pos,tcolor) | |
2372 | local effect=self.SparkEffect:Clone() | |
2373 | effect.BrickColor = tcolor | |
2374 | effect.CFrame = CFrame.new(pos) | |
2375 | effect.Parent = game.Workspace | |
2376 | local effectVel = Instance.new("BodyVelocity") | |
2377 | effectVel.maxForce = Vector3.new(99999, 99999, 99999) | |
2378 | effectVel.velocity = Vector3.new(math.random() * 15 * SigNum(math.random( - 10, 10)), math.random() * 15 * SigNum(math.random( - 10, 10)), math.random() * 15 * SigNum(math.random( - 10, 10))) | |
2379 | effectVel.Parent = effect | |
2380 | effect.Size = Vector3.new(math.abs(effectVel.velocity.x)/30, math.abs(effectVel.velocity.y)/30, math.abs(effectVel.velocity.z)/30) | |
2381 | wait() | |
2382 | effectVel:Destroy() | |
2383 | local effecttime = .5 | |
2384 | game.Debris:AddItem(effect, effecttime * 2) | |
2385 | local startTime = time() | |
2386 | while time() - startTime < effecttime do | |
2387 | if effect ~= nil then | |
2388 | effect.Transparency = (time() - startTime)/effecttime | |
2389 | end | |
2390 | wait() | |
2391 | end | |
2392 | if effect ~= nil then | |
2393 | effect.Parent = nil | |
2394 | end | |
2395 | end | |
2396 | ||
2397 | function GunObject:HitEffect(pos,tcolor,numSparks) | |
2398 | for i = 0, numSparks, 1 do | |
2399 | Spawn(function() self:MakeSpark(pos,tcolor) end) | |
2400 | end | |
2401 | ||
2402 | end | |
2403 | ||
2404 | --[[/Member functions]] | |
2405 | ||
2406 | ||
2407 | --[[Static functions]] | |
2408 | ||
2409 | function Round(number, decimal) | |
2410 | decimal = decimal or 0 | |
2411 | local mult = 10^decimal | |
2412 | return math.floor(number * mult + .5)/mult | |
2413 | end | |
2414 | ||
2415 | function SigNum(num) | |
2416 | if num == 0 then return 1 end | |
2417 | return math.abs(num)/num | |
2418 | end | |
2419 | ||
2420 | --this is a little bad, but shouldn't really be part of the 'class' of the gun | |
2421 | local Intangibles = {shock=1, bolt=1, bullet=1, plasma=1, effect=1, laser=1, handle=1, effects=1, flash=1,} | |
2422 | function CheckIntangible(hitObj) | |
2423 | print(hitObj.Name) | |
2424 | return Intangibles[(string.lower(hitObj.Name))] or hitObj.Transparency == 1 | |
2425 | end | |
2426 | ||
2427 | function CastRay(startpos, vec, length, ignore, delayifhit) | |
2428 | if length > 999 then | |
2429 | length = 999 | |
2430 | end | |
2431 | hit, endpos2 = game.Workspace:FindPartOnRay(Ray.new(startpos, vec * length), ignore) | |
2432 | if hit ~= nil then | |
2433 | if CheckIntangible(hit) then | |
2434 | if delayifhit then | |
2435 | wait() | |
2436 | end | |
2437 | hit, endpos2 = CastRay(endpos2 + (vec * .01), vec, length - ((startpos - endpos2).magnitude), ignore, delayifhit) | |
2438 | end | |
2439 | end | |
2440 | return hit, endpos2 | |
2441 | end | |
2442 | ||
2443 | function DrawBeam(beamstart, beamend, clr, fadedelay, templatePart) | |
2444 | local dis = 2 --(beamstart - beamend).magnitude | |
2445 | local tlaser=templatePart:Clone() | |
2446 | tlaser.BrickColor = clr | |
2447 | tlaser.Size = Vector3.new(.1, .1, dis + .2) | |
2448 | tlaser.CFrame = CFrame.new((beamend+beamstart)/2, beamstart) * CFrame.new(0, 0, - dis/2) | |
2449 | tlaser.Parent = game.Workspace | |
2450 | game.Debris:AddItem(tlaser, fadedelay) | |
2451 | end | |
2452 | ||
2453 | --[[/Static functions]] | |
2454 | ||
2455 | ||
2456 | GunObject:Initialize() | |
2457 | end)) | |
2458 | LocalScript35.Name = "BackGun" | |
2459 | LocalScript35.Parent = Tool0 | |
2460 | table.insert(cors,sandbox(LocalScript35,function() | |
2461 | --made by alextomcool!!!---Edited by Sparttan. | |
2462 | --to use: put in type of gun: barrel point left, barrel point right or bull-pup(main hande is in the middle of the gun) | |
2463 | --step 2: put in what type of wepoan it is: assult rifle or pistol(there will be more) | |
2464 | --to do list: make it easyer to modife how it weld's. | |
2465 | guntype = 1--1 is assult rifle, 2 is bullpup, 3 is pistol, 4 is knife | |
2466 | weldmode = 3--1 is barrel point upper-left, 2 is barrel pointing upper-right, 3 is barrel point lower-left and 4 is barrel point lower-right | |
2467 | -------(note: if it is pistol or knife then 1 is on right leg, 2 is on left leg, 3 is in the back of your pants and 4 is in the front of your pants) | |
2468 | model = nil--gun model, that is | |
2469 | distance = 0.75--this is the distance between the part(torso/leg) and the gun. DON'T MAKE negitive | |
2470 | rotation = 45--this is the turning in degrees. | |
2471 | --this area is mode more for someone who's already good at gun's. please do not get mad at me if you don't understand what's under here | |
2472 | y = 0--this is what's added to the current y value. positive number's make it go down. negative make's it go up | |
2473 | x = 0--this is what's added to the x value(it's really the z value but it look's like the x value when on your back). positive number's make it go left. negative make's it go right | |
2474 | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
2475 | --I suggest not doing anything else under here. All you should have to change is the weldmode and guntype. | |
2476 | --guntype 1 and weldmode 1 is for assault. guntype 3 and weldmode 1 is pistol position. | |
2477 | --Those are what I have done so far so give me time so I can edit them into the correct position. | |
2478 | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
2479 | parts = {} | |
2480 | local n = 1 | |
2481 | --can i have my | |
2482 | function on(mouse) | |
2483 | if model == nil then | |
2484 | n = 1 | |
2485 | local m = Instance.new("Model") | |
2486 | local all = script.Parent:GetChildren() | |
2487 | for i = 1, #all do | |
2488 | if all[i].className == "Part" then | |
2489 | parts[n] = all[i].Transparency | |
2490 | local brick = all[i]:clone() | |
2491 | brick.Parent = m | |
2492 | n = n +1 | |
2493 | end | |
2494 | end | |
2495 | wait() | |
2496 | if model == nil then | |
2497 | local weld = script:FindFirstChild("Weld2") | |
2498 | if weld ~= nil then | |
2499 | local new = weld:clone() | |
2500 | new.Disabled = false | |
2501 | new.Parent = m | |
2502 | m.Name = script.Parent.Name | |
2503 | m.Parent = script.Parent.Parent | |
2504 | model = m | |
2505 | local handle = model:FindFirstChild("Handle") | |
2506 | if handle ~= nil then | |
2507 | -------------------------------------------------------------------------------- | |
2508 | -------------------------------------------------------------------------------- | |
2509 | -------------------------------------------------------------------------------- | |
2510 | -------------------------------------------------------------------------------- | |
2511 | -------------------------------------------------------------------------------- | |
2512 | if guntype == 1 then | |
2513 | local torso = model.Parent:FindFirstChild("Torso") | |
2514 | if torso ~= nil then | |
2515 | if weldmode == 1 then--barrel pointing upper-right | |
2516 | local w = Instance.new("Weld") | |
2517 | w.Part0 = torso | |
2518 | w.Parent = w.Part0 | |
2519 | w.Part1 = handle | |
2520 | w.C1 = CFrame.new(distance *-1, 0.25 +y, -0.75 +x *-1) * CFrame.fromEulerAnglesXYZ(math.rad(rotation *-1), (math.pi / 2), 0) | |
2521 | elseif weldmode == 2 then--barrel pointing upper-left | |
2522 | local w = Instance.new("Weld") | |
2523 | w.Part0 = torso | |
2524 | w.Parent = w.Part0 | |
2525 | w.Part1 = handle | |
2526 | w.C1 = CFrame.new(distance, 0.25 +y, -0.75 +x *-1) * CFrame.fromEulerAnglesXYZ(math.rad(rotation *-1), (math.pi / 2 ) *-1, 0) | |
2527 | elseif weldmode == 3 then--barrel pointing upside-right | |
2528 | local w = Instance.new("Weld") | |
2529 | w.Part0 = torso | |
2530 | w.Parent = w.Part0 | |
2531 | w.Part1 = handle | |
2532 | w.C1 = CFrame.new(distance *-1, -0.1+y, 0.2 +x *-1) * CFrame.fromEulerAnglesXYZ(math.rad(rotation), (math.pi / 2), -1.5) | |
2533 | elseif weldmode == 4 then--barrel pointing upside-left | |
2534 | local w = Instance.new("Weld") | |
2535 | w.Part0 = torso | |
2536 | w.Parent = w.Part0 | |
2537 | w.Part1 = handle | |
2538 | w.C1 = CFrame.new(distance, 0.25+y, -0.75 +x *-1) * CFrame.fromEulerAnglesXYZ(math.rad(rotation), (math.pi / 2 +rotation) *-1.1, 1) | |
2539 | end | |
2540 | end | |
2541 | -------------------------------------------------------------------------------- | |
2542 | -------------------------------------------------------------------------------- | |
2543 | -------------------------------------------------------------------------------- | |
2544 | -------------------------------------------------------------------------------- | |
2545 | -------------------------------------------------------------------------------- | |
2546 | elseif guntype == 2 then--BullPup | |
2547 | local torso = model.Parent:FindFirstChild("Torso") | |
2548 | if torso ~= nil then | |
2549 | if weldmode == 1 then--barrel pointing upper-right | |
2550 | local w = Instance.new("Weld") | |
2551 | w.Part0 = torso | |
2552 | w.Parent = w.Part0 | |
2553 | w.Part1 = handle | |
2554 | w.C1 = CFrame.new(distance *-1, 0.25+y, -0.5 +x *-1) * CFrame.fromEulerAnglesXYZ(math.rad(rotation *-1), math.pi / 2, 0) | |
2555 | elseif weldmode == 2 then--barrel pointing upper-left | |
2556 | local w = Instance.new("Weld") | |
2557 | w.Part0 = torso | |
2558 | w.Parent = w.Part0 | |
2559 | w.Part1 = handle | |
2560 | w.C1 = CFrame.new(distance, 0.25 +y, -0.5 +x *-1) * CFrame.fromEulerAnglesXYZ(math.rad(rotation *-1), math.pi / 2 *-1, 0) | |
2561 | elseif weldmode == 3 then--barrel pointing upside-right | |
2562 | local w = Instance.new("Weld") | |
2563 | w.Part0 = torso | |
2564 | w.Parent = w.Part0 | |
2565 | w.Part1 = handle | |
2566 | w.C1 = CFrame.new(distance *-1, 0.25 +y, -0.5 +x *-1) * CFrame.fromEulerAnglesXYZ(math.rad(rotation), math.pi / 2, 0) | |
2567 | elseif weldmode == 4 then--barrel pointing upside-left | |
2568 | local w = Instance.new("Weld") | |
2569 | w.Part0 = torso | |
2570 | w.Parent = w.Part0 | |
2571 | w.Part1 = handle | |
2572 | w.C1 = CFrame.new(distance, 0.25 +y, -0.5 +x *-1) * CFrame.fromEulerAnglesXYZ(math.rad(rotation), math.pi / 2 *-1, 0) | |
2573 | end | |
2574 | end | |
2575 | -------------------------------------------------------------------------------- | |
2576 | -------------------------------------------------------------------------------- | |
2577 | -------------------------------------------------------------------------------- | |
2578 | -------------------------------------------------------------------------------- | |
2579 | -------------------------------------------------------------------------------- | |
2580 | elseif guntype == 3 then--pistol | |
2581 | local lleg = model.Parent:FindFirstChild("Left Leg") | |
2582 | local rleg = model.Parent:FindFirstChild("Right Leg") | |
2583 | if lleg ~= nil and rleg ~= nil then | |
2584 | if weldmode == 1 then--pistol on right leg | |
2585 | local w = Instance.new("Weld") | |
2586 | w.Part0 = rleg | |
2587 | w.Parent = w.Part0 | |
2588 | w.Part1 = handle | |
2589 | w.C1 = CFrame.new(distance *-1, 0 +y, -0.25 +x *-1) * CFrame.fromEulerAnglesXYZ(math.pi / 2, 0, 0) | |
2590 | elseif weldmode == 2 then--pistol on left leg | |
2591 | local w = Instance.new("Weld") | |
2592 | w.Part0 = lleg | |
2593 | w.Parent = w.Part0 | |
2594 | w.Part1 = handle | |
2595 | w.C1 = CFrame.new(distance, 0 +y, -0.25 +x *-1) * CFrame.fromEulerAnglesXYZ(math.pi / 2, 0, 0) | |
2596 | elseif weldmode == 3 then--knife in pant's back, gangsta like | |
2597 | local w = Instance.new("Weld") | |
2598 | w.Part0 = torso | |
2599 | w.Parent = w.Part0 | |
2600 | w.Part1 = handle | |
2601 | w.C1 = CFrame.new(distance *-1, 0 +y, 0.25 +x) * CFrame.fromEulerAnglesXYZ(math.pi / 2 , math.pi / 2, 0) | |
2602 | elseif weldmode == 4 then--knife in pant's front, gangsta like | |
2603 | local w = Instance.new("Weld") | |
2604 | w.Part0 = torso | |
2605 | w.Parent = w.Part0 | |
2606 | w.Part1 = handle | |
2607 | w.C1 = CFrame.new(distance, 0 +y, 0.25 +x) * CFrame.fromEulerAnglesXYZ(math.pi / 2 , math.pi / 2 *-1, 0) | |
2608 | end | |
2609 | end | |
2610 | -------------------------------------------------------------------------------- | |
2611 | -------------------------------------------------------------------------------- | |
2612 | -------------------------------------------------------------------------------- | |
2613 | -------------------------------------------------------------------------------- | |
2614 | -------------------------------------------------------------------------------- | |
2615 | elseif guntype == 4 then--knife | |
2616 | local lleg = model.Parent:FindFirstChild("Left Leg") | |
2617 | local rleg = model.Parent:FindFirstChild("Right Leg") | |
2618 | local torso = model.Parent:FindFirstChild("Torso") | |
2619 | if lleg ~= nil and rleg ~= nil and torso ~= nil then | |
2620 | if weldmode == 1 then--pistol on right leg | |
2621 | local w = Instance.new("Weld") | |
2622 | w.Part0 = rleg | |
2623 | w.Parent = w.Part0 | |
2624 | w.Part1 = handle | |
2625 | w.C1 = CFrame.new(distance *-1, 0.15 +y, -0.25 +x *-1) * CFrame.fromEulerAnglesXYZ(math.pi, 0, 0) | |
2626 | elseif weldmode == 2 then--pistol on left leg | |
2627 | local w = Instance.new("Weld") | |
2628 | w.Part0 = lleg | |
2629 | w.Parent = w.Part0 | |
2630 | w.Part1 = handle | |
2631 | w.C1 = CFrame.new(distance, 0.15 +y, -0.25 +x *-1) * CFrame.fromEulerAnglesXYZ(math.pi, 0, 0) | |
2632 | elseif weldmode == 3 then--knife in pant's back, gangsta like | |
2633 | local w = Instance.new("Weld") | |
2634 | w.Part0 = torso | |
2635 | w.Parent = w.Part0 | |
2636 | w.Part1 = handle | |
2637 | w.C1 = CFrame.new(distance *-1, 0 +y, 0.25 +x) * CFrame.fromEulerAnglesXYZ(math.pi , math.pi / 2, 0) | |
2638 | elseif weldmode == 4 then--knife in pant's front, gangsta like | |
2639 | local w = Instance.new("Weld") | |
2640 | w.Part0 = torso | |
2641 | w.Parent = w.Part0 | |
2642 | w.Part1 = handle | |
2643 | w.C1 = CFrame.new(distance, 0 +y, 0.25 +x) * CFrame.fromEulerAnglesXYZ(math.pi , math.pi / 2 *-1, 0) | |
2644 | end | |
2645 | end | |
2646 | end | |
2647 | end | |
2648 | end | |
2649 | end | |
2650 | end | |
2651 | -------------------------------------------------------------------------------- | |
2652 | -------------------------------------------------------------------------------- | |
2653 | -------------------------------------------------------------------------------- | |
2654 | -------------------------------------------------------------------------------- | |
2655 | -------------------------------------------------------------------------------- | |
2656 | if model ~= nil then | |
2657 | n = 1 | |
2658 | local all = model:GetChildren() | |
2659 | for i = 1, #all do | |
2660 | if all[i].className == "Part" then | |
2661 | all[i].Transparency = 1 | |
2662 | end | |
2663 | end | |
2664 | end | |
2665 | end | |
2666 | --check | |
2667 | function off(mouse) | |
2668 | if model ~= nil then | |
2669 | n = 1 | |
2670 | local all = model:GetChildren() | |
2671 | for i = 1, #all do | |
2672 | if all[i].className == "Part" then | |
2673 | all[i].Transparency = parts[n] | |
2674 | local Do = true | |
2675 | if Do then | |
2676 | Do = false--dude! | |
2677 | n = n +1 | |
2678 | end | |
2679 | end | |
2680 | end | |
2681 | end | |
2682 | end | |
2683 | --please? | |
2684 | script.Parent.Equipped:connect(on) | |
2685 | script.Parent.Unequipped:connect(off) | |
2686 | end)) | |
2687 | LocalScript36.Name = "Weld2" | |
2688 | LocalScript36.Parent = LocalScript35 | |
2689 | LocalScript36.Disabled = true | |
2690 | table.insert(cors,sandbox(LocalScript36,function() | |
2691 | function Weld(x,y) | |
2692 | local W = Instance.new("Weld") | |
2693 | W.Part0 = x | |
2694 | W.Part1 = y | |
2695 | local CJ = CFrame.new(x.Position) | |
2696 | local C0 = x.CFrame:inverse()*CJ | |
2697 | local C1 = y.CFrame:inverse()*CJ | |
2698 | W.C0 = C0 | |
2699 | W.C1 = C1 | |
2700 | W.Parent = x | |
2701 | end | |
2702 | ||
2703 | function Get(A) | |
2704 | if A.className == "Part" then | |
2705 | Weld(script.Parent.Handle, A) | |
2706 | A.Anchored = false | |
2707 | else | |
2708 | local C = A:GetChildren() | |
2709 | for i=1, #C do | |
2710 | Get(C[i]) | |
2711 | end | |
2712 | end | |
2713 | end | |
2714 | local yes = true | |
2715 | if yes then | |
2716 | yes = false | |
2717 | Get(script.Parent) | |
2718 | end | |
2719 | function onDied() | |
2720 | script.Parent.Parent = nil | |
2721 | end | |
2722 | h = script.Parent.Parent:FindFirstChild("Humanoid") | |
2723 | if h ~= nil then | |
2724 | h.Died:connect(onDied) | |
2725 | end | |
2726 | ||
2727 | end)) | |
2728 | Part37.Name = "Handle" | |
2729 | Part37.Parent = Tool0 | |
2730 | Part37.BrickColor = BrickColor.new("Really black") | |
2731 | Part37.Reflectance = 1 | |
2732 | Part37.Rotation = Vector3.new(90, 60, -90) | |
2733 | Part37.CanCollide = false | |
2734 | Part37.FormFactor = Enum.FormFactor.Custom | |
2735 | Part37.Size = Vector3.new(0.770000994, 0.930003285, 3.75999236) | |
2736 | Part37.CFrame = CFrame.new(-10.507762, 1.34270597, -2.33923697, 0, 0.499998987, 0.866025984, 0, 0.866025984, -0.499998987, -1, 0, 0) | |
2737 | Part37.Color = Color3.new(0.0666667, 0.0666667, 0.0666667) | |
2738 | Part37.Position = Vector3.new(-10.507762, 1.34270597, -2.33923697) | |
2739 | Part37.Orientation = Vector3.new(30, 90, 0) | |
2740 | Part37.Color = Color3.new(0.0666667, 0.0666667, 0.0666667) | |
2741 | Sound38.Name = "Fire" | |
2742 | Sound38.Parent = Part37 | |
2743 | Sound38.SoundId = "rbxassetid://636316879" | |
2744 | Sound38.Volume = 1 | |
2745 | Sound39.Name = "Reload" | |
2746 | Sound39.Parent = Part37 | |
2747 | Sound39.SoundId = "rbxassetid://145081845" | |
2748 | Sound39.Volume = 1 | |
2749 | SpecialMesh40.Parent = Part37 | |
2750 | SpecialMesh40.MeshId = "http://www.roblox.com/asset/?id=94219391" | |
2751 | SpecialMesh40.Scale = Vector3.new(0.75, 0.75, 0.75) | |
2752 | SpecialMesh40.TextureId = "rbxassetid://1153072548" | |
2753 | SpecialMesh40.MeshType = Enum.MeshType.FileMesh | |
2754 | SpecialMesh40.Scale = Vector3.new(0.75, 0.75, 0.75) | |
2755 | for i,v in pairs(mas:GetChildren()) do | |
2756 | v.Parent = game:GetService("Players").LocalPlayer.Backpack | |
2757 | pcall(function() v:MakeJoints() end) | |
2758 | end | |
2759 | mas:Destroy() | |
2760 | for i,v in pairs(cors) do | |
2761 | spawn(function() | |
2762 | pcall(v) | |
2763 | end) | |
2764 | end |