Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

What is a LoadLibrary Alternative?

Ok so, I have a gun script, but it includes "LoadLibrary" which is deprecated. How can I change this without breaking the script? (Line 10)

local player = game.Players.LocalPlayer
	local backpack, playergui = player:WaitForChild("Backpack"), player:WaitForChild("PlayerGui")
	repeat wait(0.1) until player.Character
		local char, camera = player.Character, workspace.CurrentCamera
local tool = script.Parent
	local handle = tool:WaitForChild("Handle")
	local barrel= tool:WaitForChild("Barrel")
local GunGUI = tool:WaitForChild("GunGUI")

local create = assert(LoadLibrary("RbxUtility")).Create
local storage = game:GetService("ReplicatedStorage")
local debris = game:GetService("Debris")

local cframe, cframeXYZ, vector = CFrame.new, CFrame.fromEulerAnglesXYZ, Vector3.new

local arms = {
	Left = cframe(-0.249, 1.35, 0.6) * cframeXYZ(math.rad(290), 0, math.rad(-90)),
    Right = cframe(-0.7, 0.4, 0.35) * cframeXYZ(math.rad(-90),math.rad(-5),math.rad(0)),}
local cursor = {
	Standard = "http://www.roblox.com/asset/?id=275897531",
}

local creator = create("ObjectValue"){Name = "creator", Value = player}

local laser = create("Part"){Name = "Ray", Anchored = true, CanCollide = false, formFactor = 0, Size = vector(1, 1, 1), BrickColor = BrickColor.new("Bright yellow"),Material = Enum.Material.Neon, Reflectance = 0.3, Transparency = 0.25} --0.25
local light = Instance.new("PointLight",laser)
light.Range = 6
light.Color = Color3.new(255,255,0)
light.Brightness = 10

local mesh = create("BlockMesh"){Parent = laser, Name = "Mesh", Scale = Vector3.new(0.15, 0.15, 1)}

local armToggle = char:FindFirstChild("armToggle") and char.armToggle or create("BoolValue"){Parent = char, Name = "armToggle"}

2 comments

1

LoadLibrary("RbxUtility").Create() is literally just Instance.new()

1

Stop micro optimising

1 answer

I think I covered everything in this. Don't use free models, please, and consider the comment I left on the main thread.

local player = game.Players.LocalPlayer
    local backpack, playergui = player:WaitForChild("Backpack"), player:WaitForChild("PlayerGui")
    repeat wait(0.1) until player.Character
        local char, camera = player.Character, workspace.CurrentCamera
local tool = script.Parent
    local handle = tool:WaitForChild("Handle")
    local barrel= tool:WaitForChild("Barrel")
local GunGUI = tool:WaitForChild("GunGUI")
local storage = game:GetService("ReplicatedStorage")
local debris = game:GetService("Debris")

local cframe, cframeXYZ, vector = CFrame.new, CFrame.fromEulerAnglesXYZ, Vector3.new

local arms = {
    Left = cframe(-0.249, 1.35, 0.6) * cframeXYZ(math.rad(290), 0, math.rad(-90)),
    Right = cframe(-0.7, 0.4, 0.35) * cframeXYZ(math.rad(-90),math.rad(-5),math.rad(0)),}
local cursor = {
    Standard = "http://www.roblox.com/asset/?id=275897531",
}

local creator = Instance.new("ObjectValue")
creator.Name = "creator"
creator.Value = player

local laser = Instance.new("Part")
laser.Name = "Ray"
laser.Anchored = true
laser.CanCollide = false
laser.Size = Vector3.new(1,1,1)
laser.BrickColor = BrickColor.new("Bright yellow")
laser.Material = Enum.Material.Neon
laser.Reflectance = .3
laser.Transparency = .25
local light = Instance.new("PointLight")
light.Range = 6
light.Color = Color3.new(255,255,0)
light.Brightness = 10
light.Parent = laser

local mesh = Instance.new("BlockMesh")
mesh.Parent = laser
mesh.Name = "Mesh"
mesh.Scale = Vector3.new(.15,.15,1)

if not char:FindFirstChild("armToggle") then
   local armToggle = Instance.new("BoolValue")
   armToggle.Name = "armToggle"
   armToggle.Parent = char
end

2 comments

0

nice explanation.............

0

there's nothing to explain other than what i said in my comment

This discussion is preserved as it was. New answers, comments, and votes are closed.