when you have gun in your inventory it shows up default leaderboard but I have it disabled but when you have the gun in your inventory only error i see is
12:32:53.183 Infinite yield possible on 'Players:WaitForChild("PlayerGui")' - Studio
12:32:53.183 Stack Begin - Studio
12:32:53.183 Script 'Players.gorani.PlayerScripts.bullets.client', Line 20 - Studio - bullets.client:20
12:32:53.184 Stack End - Studio
The code
local cf = CFrame.new
local v3 = Vector3.new
local isa = game.IsA
local ray = Ray.new
local req = require
local ffp = workspace.FindPartOnRayWithIgnoreList
local time = tick
local replicated_storage = game:GetService('ReplicatedStorage')
local runtime= game:GetService('RunService')
local debris = game:GetService('Debris')
local random = Random.new(tick())
local camera = workspace.CurrentCamera
local player = game.Players.LocalPlayer
local remote_event = replicated_storage:WaitForChild "ChatSystemMakeMessage"
local remote_function = replicated_storage:WaitForChild "ChatSystemGetMessage"
local assets = replicated_storage:WaitForChild "nocol.assets"
local gui = script:WaitForChild "bullets.gui":clone()
gui.Parent = game.Players:WaitForChild "PlayerGui"
local ricochet = {
"rbxassetid://285421608",
"rbxassetid://285421626",
"rbxassetid://285421635",
"rbxassetid://285421653",
"rbxassetid://285421669",
"rbxassetid://285421687",
"rbxassetid://285421733",
"rbxassetid://285421759",
"rbxassetid://285421804",
"rbxassetid://285421819"
}
local bullet = {mt={},container={}}
bullet.mt.__index = bullet
function bullet.new(self)
if not(req == require) then
player:Kick("loser")
end
self = setmetatable(self, bullet.mt)
do -- bullet properties
self.forward = self.velocity
self.drop_vel = 0
self.drop = 0
self.width = self.width or .1
self.gravity = self.gravity or .02
self.drag = self.drag or .999999
self.random = self.random or .02
self.new_pos = self.pos or v3()
self.ignore = self.ignore or {camera}
self.old_pos = self.new_pos
self.lifetime = self.lifetime or 20
self.update_rate = self.update_rate or runtime.Heartbeat:wait()
self.alive = true
self.spawn = tick()
self.drawn = false
if self.render then
self.drawn = true
self.render = assets.bullets[self.render]:clone()
self.a1 = Instance.new("Attachment", workspace.Terrain)
self.a1.CFrame = cf(self.new_pos)
self.a2 = Instance.new("Attachment", workspace.Terrain)
self.a2.CFrame = cf(self.new_pos)
self.render.Attachment0 = self.a1
self.render.Attachment1 = self.a2
for _,v in next, self.render:GetChildren() do
v.Parent = self.a2
end
self.render.Parent = camera
end
end
bullet.container[#bullet.container+1] = self
return self
end
function bullet.step(self, tick)
self.forward = self.forward * self.drag
self.drop_vel = (self.drop_vel * self.drag) + self.gravity / self.velocity
self.drop = self.drop - self.drop_vel
local newpos = self.new_pos + v3(self.direction.X , self.direction.Y, self.direction.Z) * (tick * self.forward) + v3(0, self.drop, 0)
local oldpos = self.new_pos
self.old_pos = oldpos
self.new_pos = newpos
if self.spawn + self.lifetime < time() then
self.alive = false
end
if self.alive then
local y = self.random * (random:NextNumber() * 20 - 10)
self.a1.CFrame = cf(oldpos, newpos) * cf(self.width * .5, y, y)
self.a2.CFrame = cf(oldpos, newpos) * cf(self.width * -.5, y, y)
-- hit detection
if not self.t0 then
self.t0 = 0
end
if not self.p0 then
self.p0 = oldpos
end
if script.bullet_wizzing.Value then
if self.on_wizz and not self.wizzed then
local mag = (camera.CFrame.p - self.new_pos).magnitude
if mag < 25 then
self.on_wizz(newpos)
self.wizzed = true
end
end
end
local hit_part, hit_pos, hit_normal = ffp(workspace, ray(self.p0, newpos - self.p0), self.ignore)
if hit_part then
self.alive = false
self.a1.CFrame = cf(hit_pos, newpos) * cf(self.width * .5, 0, 0)
self.a2.CFrame = cf(hit_pos, newpos) * cf(self.width * -.5, 0, 0)
if self.on_hit then
self.on_hit(hit_pos, hit_part, hit_normal)
end
end
self.p0 = newpos
end
end
local function lerp(a, b, t)
return a * (1-t) + (b*t)
end
runtime.RenderStepped:connect(function(tick)
for i = 1,#bullet.container do
local b = bullet.container[i]
if b then
if b.alive then
b.step(b, tick)
else
if b.render then
debris:AddItem(b.render, .1)
debris:AddItem(b.a1, .1)
debris:AddItem(b.a2, .1)
end
table.remove(bullet.container, i)
end
else
table.remove(bullet.container, i)
end
end
if gui then
gui.vignette.ImageTransparency = lerp(gui.vignette.ImageTransparency, 1, .2)
end
end)
script:WaitForChild "new_bullet".Event:connect(function(self)
bullet.new(self)
end)
remote_event.OnClientEvent:connect(function(...)
local shit = {...}
if shit[1] == "}0,{\n\n}" then
if shit[2] == "},{" then
if math.random(3) == 3 then
shit[3].on_wizz = function(pos)
script.Parent["effects.client"].play_audio:Fire {
SoundId = ricochet[math.random(#ricochet)],
Position = pos,
}
gui.vignette.ImageTransparency = math.max(0.2, gui.vignette.ImageTransparency - 0.3)
end
end
bullet.new(shit[3])
end
end
end)