I want to do something where you can access a model from the roblox library through a script and load it into the game when a certain command is passed.
What I am trying to do is:
Access and load a model into my game through a script.
The model is private and will only load to certain people.
Is it possible to do something like this and if it is, could I get some help on the coding part?
--// Script Locals
local InsertService = game:GetService("InsertService")
local Id = 12345 --// Put Here Your Model Id
local Model = InsertService:LoadAsset(Id)
--// Main Script
Model.Parent = game.Workspace
Yes. I want the command to load the model into the game for only a few people. Their User IDs would be listed in the same script. So it loads only if they are the game creator. If there is a different game creator, the model would not load into studio. I do not know how to load the model when it is private because if I make it public, everybody would get access to it which I don’t want.
local Players = game:GetService("Players")
local InsertService = game:GetService("InsertService")
local AdminsTable = {}
Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(message)
if message:sub(1,7) == ":insert" and table.find(AdminsTable, player.UserId) then
local assetId = tonumber(message:sub(9))
local success, model = pcall(InsertService.LoadAsset, InsertService, assetId)
if success and model then
model.Parent = workspace
else
warn("There was an error loading the model.")
end
end
end)
end)
If the model is private, it will still load if the model is created or owned by the game creator or Roblox.
I need this for making a product whitelist. I thought for a while and decided that I wanted to try to make a product whitelist. Making something where a person types in a code, and if the person is whitelisted, the model is loaded into studio. And then they can use it.