local toolbar = plugin:CreateToolbar("Insert Decal")-- Make The Plugin ToolBar And Name
local Button = toolbar:CreateButton( --Create A Button
"Insert Decal", --Name of Plugin
"Insert a file decal to workspace.", --What Is Says When You Hover Over The Plugin
"http://www.roblox.com/asset/?id=9375337100" --Image of The Plugin rbxassetid://12345678
)
local studioservice = game.StudioService
local history = game:GetService("ChangeHistoryService")
Button.Click:Connect(function() --- Add Whatever You Want Here
local filee = studioservice:PromptImportFile({"png","jpg"})
if filee ~= nil then
history:SetWaypoint("start insert decal")
local part = Instance.new("Part")
local decal = Instance.new("Decal")
print(filee:GetTemporaryId())
decal.Texture = filee:GetTemporaryId()
decal.Parent = part
part.Name = filee.Name
part.Size = Vector3.new(5, 5, 2.5)
part.Position = workspace.CurrentCamera.CFrame.Position
part.Parent = workspace
local importedecals = game.ServerStorage:FindFirstChild("ImportedDecals")
if importedecals then
local clonedpart = part:Clone()
clonedpart.Parent = importedecals
else
local folder = Instance.new("Folder")
folder.Name = "ImportedDecals"
folder.Parent = game.ServerStorage
local clonedpart = part:Clone()
clonedpart.Parent = game.ServerStorage:FindFirstChild("ImportedDecals")
end
history:SetWaypoint("end insert decal")
end
end)
local toolbar = plugin:CreateToolbar("Insert Decal")-- Make The Plugin ToolBar And Name
local Button = toolbar:CreateButton( --Create A Button
"Insert Decal", --Name of Plugin
"Insert a file decal to workspace.", --What Is Says When You Hover Over The Plugin
"http://www.roblox.com/asset/?id=9375337100" --Image of The Plugin rbxassetid://12345678
)
local studioservice = game.StudioService
local history = game:GetService("ChangeHistoryService")
Button.Click:Connect(function() --- Add Whatever You Want Here
local filee = studioservice:PromptImportFiles({"png","jpg"})
if #filee ~= 0 then
history:SetWaypoint("start insert decal")
for i,dafile in pairs(filee) do
local part = Instance.new("Part")
local decal = Instance.new("Decal")
print(dafile:GetTemporaryId())
part.TopSurface = Enum.SurfaceType.SmoothNoOutlines
decal.Texture = dafile:GetTemporaryId()
decal.Parent = part
part.Size = Vector3.new(5, 5, 2.5)
part.Name = dafile.Name
part.Position = workspace.CurrentCamera.CFrame.Position
part.Parent = workspace
part.BottomSurface = Enum.SurfaceType.SmoothNoOutlines
local importedecals = game.ServerStorage:FindFirstChild("ImportedDecals")
if string.sub(dafile.Name,string.len(dafile.Name)-2,string.len(dafile.Name)) == "png" then
local data = dafile:GetBinaryContents()
local IHDR_start, IHDR_end = data:find("IHDR")
local DIM_BYTES = 4
local width_start = IHDR_end
local height_start = width_start + DIM_BYTES
local width, height = 0, 0
for i = 1, DIM_BYTES do
local byte = string.byte(data:sub(width_start+i, width_start+i)) --turn each character into a number matching the byte that codes for said character
width += bit32.lshift(byte, 8 * (DIM_BYTES-i)) --lshifting because first bytes are most significant
end
for i = 1, DIM_BYTES do
local byte = string.byte(data:sub(height_start+i, height_start+i))
height += bit32.lshift(byte, 8 * (DIM_BYTES-i))
end
part.Size = Vector3.new(width/100,height/100,1)
end
if importedecals then
local clonedpart = part:Clone()
clonedpart.Parent = importedecals
else
local folder = Instance.new("Folder")
folder.Name = "ImportedDecals"
folder.Parent = game.ServerStorage
local clonedpart = part:Clone()
clonedpart.Parent = game.ServerStorage:FindFirstChild("ImportedDecals")
end
end
history:SetWaypoint("end insert decal")
end
end)
Wait hold up-
You can access files from the desktop from studio? Doesn’t this prompt huge security issues? What if somebody uploads something not so good here? Although this is very very cool