“ProfileData” is a table of the users database, i am using profileservice for the datastore
local function ViewportIcon(Viewport, GunName, GunModule)
local ViewportModel = GunModels:WaitForChild(GunName).Gun:Clone()
local ViewportCamera = Instance.new("Camera")
ViewportModel.Parent = Viewport
ViewportModel.Name = GunName
ViewportCamera.Parent = Viewport
ViewportCamera.FieldOfView = 30
for _, Child in pairs(ViewportModel:GetDescendants()) do
if Child:IsA("BasePart") then
Child.Color = Color3.fromRGB(255, 255, 255)
Child.Material = Enum.Material.SmoothPlastic
end
end
Viewport.CurrentCamera = ViewportCamera
local CF, _Size_ = ViewportModel:GetBoundingBox()
ViewportCamera.CFrame = GunModule.LobbyIconCFrame
end
-- Weapons
for _, Button in pairs(UI.Pages.Weapons.Buttons:GetChildren()) do
-- Mouse Enter
Button.MouseEnter:Connect(function()
Button.Label.TextColor3 = Color3.fromRGB(212, 170, 50)
Sounds.Hover:Play()
if ProfileData.Loadouts[Button.Name] then
UI.Pages.Weapons.View.Primary.WeaponName.Text = ProfileData.Loadouts[Button.Name].Primary.Weapon
UI.Pages.Weapons.View.Secondary.WeaponName.Text = ProfileData.Loadouts[Button.Name].Secondary.Weapon
local PrimaryGunInfo = require(GunModules:WaitForChild(ProfileData.Loadouts[Button.Name].Primary.Weapon))
local SecondaryGunInfo = require(GunModules:WaitForChild(ProfileData.Loadouts[Button.Name].Secondary.Weapon))
ViewportIcon(ViewportFrame, ProfileData.Loadouts[Button.Name].Primary.Weapon, PrimaryGunInfo)
end
end)
i have this script to show icons for a loadout screen but it is very laggy