SHOW:
|
|
- or go back to the newest paste.
1 | --Turrets Gifted by machontz, Regular Script! | |
2 | ||
3 | - | me = game.Players.RoyalOOBatManOo |
3 | + | me = game.Players.Deishuu_Kaiki |
4 | ||
5 | ||
6 | ||
7 | if script.Parent.className ~= "HopperBin" then | |
8 | ||
9 | h = Instance.new("HopperBin",me.Backpack) | |
10 | ||
11 | h.Name = "Turrets" | |
12 | ||
13 | script.Parent = h | |
14 | ||
15 | end | |
16 | ||
17 | ||
18 | ||
19 | bin = script.Parent | |
20 | ||
21 | ||
22 | ||
23 | function prop(part, parent, collide, tran, ref, x, y, z, color, anchor) | |
24 | ||
25 | part.Parent = parent | |
26 | ||
27 | part.formFactor = 0 | |
28 | ||
29 | part.CanCollide = collide | |
30 | ||
31 | part.Transparency = tran | |
32 | ||
33 | part.Reflectance = ref | |
34 | ||
35 | part.Size = Vector3.new(x,y,z) | |
36 | ||
37 | part.BrickColor = BrickColor.new(color) | |
38 | ||
39 | part.TopSurface = 0 | |
40 | ||
41 | part.BottomSurface = 0 | |
42 | ||
43 | part.Anchored = anchor | |
44 | ||
45 | part:BreakJoints() | |
46 | ||
47 | end | |
48 | ||
49 | ||
50 | ||
51 | function weld(w, p, p0, p1, a, b, c, x, y, z) | |
52 | ||
53 | w.Parent = p | |
54 | ||
55 | w.Part0 = p0 | |
56 | ||
57 | w.Part1 = p1 | |
58 | ||
59 | w.C1 = CFrame.fromEulerAnglesXYZ(a,b,c) * CFrame.new(x,y,z) | |
60 | ||
61 | end | |
62 | ||
63 | ||
64 | ||
65 | function mesh(mesh, parent, x, y, z, type) | |
66 | ||
67 | mesh.Parent = parent | |
68 | ||
69 | mesh.Scale = Vector3.new(x, y, z) | |
70 | ||
71 | mesh.MeshType = type | |
72 | ||
73 | end | |
74 | ||
75 | ||
76 | ||
77 | function placeturret(mainplace) | |
78 | ||
79 | local turret = Instance.new("Model",workspace) | |
80 | ||
81 | turret.Name = "Turret" | |
82 | ||
83 | ||
84 | ||
85 | local main = Instance.new("Part") | |
86 | ||
87 | prop(main, turret, true, 0, 0, 3, 1, 3, "Dark grey", true) | |
88 | ||
89 | main.CFrame = CFrame.new(mainplace) | |
90 | ||
91 | mainmesh = Instance.new("CylinderMesh",main) | |
92 | ||
93 | ||
94 | ||
95 | local neck = Instance.new("Part") | |
96 | ||
97 | prop(neck,turret,true,0,0,1,2,1,"Dark grey", true) | |
98 | ||
99 | neck.CFrame = CFrame.new(mainplace) * CFrame.new(0,1.1,0) | |
100 | ||
101 | neckmesh = Instance.new("CylinderMesh",neck) | |
102 | ||
103 | neckmesh.Scale = Vector3.new(1,1.5,1) | |
104 | ||
105 | ||
106 | ||
107 | local move = Instance.new("Part") | |
108 | ||
109 | prop(move, turret, false, 0, 0, 1, 1, 5,"Dark grey", false) | |
110 | ||
111 | move.CFrame = CFrame.new(mainplace) * CFrame.new(0,3,0) | |
112 | ||
113 | ||
114 | ||
115 | local bg = Instance.new("BodyGyro") | |
116 | ||
117 | bg.Parent = move | |
118 | ||
119 | bg.maxTorque = Vector3.new(1e+008,1e+008,1e+008) | |
120 | ||
121 | ||
122 | ||
123 | local bp = Instance.new("BodyPosition",move) | |
124 | ||
125 | bp.maxForce = Vector3.new(1e+008,1e+008,1e+008) | |
126 | ||
127 | bp.position = bp.Parent.Position | |
128 | ||
129 | ||
130 | ||
131 | local gunner = Instance.new("Part") | |
132 | ||
133 | gunner.FrontSurface = "Hinge" | |
134 | ||
135 | prop(gunner,turret,true,0,0,1,1,1,"Dark grey",false) | |
136 | ||
137 | gunner.CFrame = CFrame.new(mainplace) * CFrame.new(0,3,2.5) | |
138 | ||
139 | ||
140 | ||
141 | local gunweld = Instance.new("Weld") | |
142 | ||
143 | weld(gunweld,move,move,gunner,0,0,0,0,0,2.5) | |
144 | ||
145 | ||
146 | ||
147 | local sound = Instance.new("Sound",gunner) | |
148 | ||
149 | sound.Volume = 0.8 | |
150 | ||
151 | sound.Pitch = 4 | |
152 | ||
153 | sound.SoundId = "http://www.roblox.com/asset/?id=2760979" | |
154 | ||
155 | ||
156 | ||
157 | function find(pos) | |
158 | ||
159 | local list = game.Workspace:children() | |
160 | ||
161 | local torso = nil | |
162 | ||
163 | local dist = 40 | |
164 | ||
165 | local temp = nil | |
166 | ||
167 | local human = nil | |
168 | ||
169 | local temp2 = nil | |
170 | ||
171 | for x = 1, #list do | |
172 | ||
173 | temp2 = list[x] | |
174 | ||
175 | if (temp2.className == "Model") and (temp2 ~= script.Parent) then | |
176 | ||
177 | temp = temp2:findFirstChild("Torso") | |
178 | ||
179 | human = temp2:findFirstChild("Humanoid") | |
180 | ||
181 | if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then | |
182 | ||
183 | if (temp.Position - pos).magnitude < dist then | |
184 | ||
185 | torso = temp | |
186 | ||
187 | dist = (temp.Position - pos).magnitude | |
188 | ||
189 | end | |
190 | ||
191 | end | |
192 | ||
193 | end | |
194 | ||
195 | end | |
196 | ||
197 | return torso | |
198 | ||
199 | end | |
200 | ||
201 | ||
202 | ||
203 | coroutine.resume(coroutine.create(function() | |
204 | ||
205 | while true do | |
206 | ||
207 | if gunner.Parent ~= nil then | |
208 | ||
209 | wait(0.1) | |
210 | ||
211 | local target = find(gunner.Position) | |
212 | ||
213 | if target ~= nil then | |
214 | ||
215 | bg.cframe = CFrame.new(move.Position, target.Position) | |
216 | ||
217 | local meh = math.random(1,6) | |
218 | ||
219 | if meh == 1 then | |
220 | ||
221 | local bulls = {} | |
222 | ||
223 | local dis = (gunner.Position - target.Position).magnitude | |
224 | ||
225 | local bullet = Instance.new("Part") | |
226 | ||
227 | prop(bullet,workspace,false,0,0,1,1,1,"Bright yellow",true) | |
228 | ||
229 | bullet.CFrame = CFrame.new(gunner.Position, target.Position) * CFrame.new(0,0,-dis/2) | |
230 | ||
231 | local meu = Instance.new("SpecialMesh") | |
232 | ||
233 | mesh(meu,bullet,0.23,0.23,dis,"Brick") | |
234 | ||
235 | local huo = target.Parent:findFirstChild("Humanoid") | |
236 | ||
237 | huo:TakeDamage(math.random(huo.MaxHealth/34,huo.MaxHealth/8)) | |
238 | ||
239 | local randompitch = math.random(500,1200)/1000 | |
240 | ||
241 | sound.Pitch = randompitch | |
242 | ||
243 | sound:play() | |
244 | ||
245 | table.insert(bulls,bullet) | |
246 | ||
247 | for i=1, math.random(3,6) do | |
248 | ||
249 | local msi = math.random(8,23)/10 | |
250 | ||
251 | local th = Instance.new("Part") | |
252 | ||
253 | prop(th,workspace,false,0,0,1,1,1,"Bright yellow",true) | |
254 | ||
255 | th.CFrame = CFrame.new(gunner.Position,target.Position) * CFrame.new(0,0,-dis) | |
256 | ||
257 | th.CFrame = th.CFrame * CFrame.Angles(math.random(-100,100),math.random(-100,100),math.random(-100,100)) | |
258 | ||
259 | th.CFrame = th.CFrame * CFrame.new(0,0,-msi/2) | |
260 | ||
261 | thme = Instance.new("SpecialMesh") | |
262 | ||
263 | mesh(thme,th,0.13,0.13,msi, "Brick") | |
264 | ||
265 | table.insert(bulls,th) | |
266 | ||
267 | for duh=1, math.random(2,5) do | |
268 | ||
269 | local bag = math.random(5,18)/10 | |
270 | ||
271 | local bah = Instance.new("Part") | |
272 | ||
273 | prop(bah,workspace,false,0,0,1,1,1,"Bright yellow",true) | |
274 | ||
275 | bah.CFrame = CFrame.new(th.Position) * CFrame.new(0,0,msi/2) | |
276 | ||
277 | bah.CFrame = bah.CFrame * CFrame.Angles(math.random(-100,100),math.random(-100,100),math.random(-100,100)) | |
278 | ||
279 | bah.CFrame = bah.CFrame * CFrame.new(0,0,-bag/2) | |
280 | ||
281 | bahme = Instance.new("SpecialMesh") | |
282 | ||
283 | mesh(bahme,bah,0.02,0.02,bag, "Brick") | |
284 | ||
285 | table.insert(bulls,bah) | |
286 | ||
287 | end | |
288 | ||
289 | end | |
290 | ||
291 | coroutine.resume(coroutine.create(function() | |
292 | ||
293 | for i=1, #bulls do | |
294 | ||
295 | coroutine.resume(coroutine.create(function() | |
296 | ||
297 | wait(0.1) | |
298 | ||
299 | for k=0, 1, 0.25 do | |
300 | ||
301 | wait() | |
302 | ||
303 | bulls[i].Transparency = k | |
304 | ||
305 | end | |
306 | ||
307 | bulls[i]:remove() | |
308 | ||
309 | end)) | |
310 | ||
311 | end | |
312 | ||
313 | end)) | |
314 | ||
315 | end | |
316 | ||
317 | end | |
318 | ||
319 | end | |
320 | ||
321 | end | |
322 | ||
323 | end)) | |
324 | ||
325 | end | |
326 | ||
327 | ||
328 | ||
329 | bin.Selected:connect(function(mouse) | |
330 | ||
331 | mouse.Button1Down:connect(function() | |
332 | ||
333 | placeturret(mouse.Hit.p) | |
334 | ||
335 | end) | |
336 | ||
337 | end) |