I’m genuinely losing sanity over this because I’ve literally made no dumb mistake here.
I’m trying to optimise my plugin auroraSuite in a move that should save a tenth of a MB of space when installing (with an RBXMX file), as well as making editing stuff in the future.
One of the steps I’m trying to accomplish this is by making multiple ImageButtons in the plugin that are generated via a script, rather than just bundling it via RBXMX.
Here’s the relevant folder structure:
The ImageButtons that are currently there are ones that aren’t being generated by the generator. They work perfectly fine and cause no conflicts with the ones I’m trying to generate using the generator.
Here is the code inside the generator script, this runs successfully on plugin launch, and my issues don’t arise from this, but with a script that the generator creates inside every ImageButton.
-- When this is completed, it'll save time by allowing me to add numerous icons on launching the plugin rather than baking it into the plugins file
local par = script.Parent
local icons = {
["home filled"] = "http://www.roblox.com/asset/?id=12815564761",
["home outlined"] = "http://www.roblox.com/asset/?id=12815570718",
["backpack filled"] = "http://www.roblox.com/asset/?id=12815630414",
["backpack outlined"] = "http://www.roblox.com/asset/?id=12815641161",
["trolley filled"] = "http://www.roblox.com/asset/?id=12816051676",
["trolley outlined"] = "http://www.roblox.com/asset/?id=12816058954",
["user filled"] = "http://www.roblox.com/asset/?id=12874654142",
["user outlined"] = "http://www.roblox.com/asset/?id=12874675901",
["left filled"] = "http://www.roblox.com/asset/?id=13683469925",
["left outlined"] = "http://www.roblox.com/asset/?id=13683473826",
["right filled"] = "http://www.roblox.com/asset/?id=13683477457",
["right outlined"] = "http://www.roblox.com/asset/?id=13683481669",
["x filled"] = "http://www.roblox.com/asset/?id=14180288939",
["x outlined"] = "http://www.roblox.com/asset/?id=14180278322",
["keyboard"] = "http://www.roblox.com/asset/?id=13683485207"
}
for name, assetid in pairs(icons) do
local icon = Instance.new("ImageButton", par)
icon.Name = name
icon.Image = assetid
icon.BackgroundTransparency = 1
icon.BorderSizePixel = 1
icon.Size = UDim2.new(0,16,0,16)
icon.Visible = true
local iconscript = Instance.new("Script", icon)
iconscript.Name = "Activation"
iconscript.Source = [[
script.Parent.MouseButton1Click:Connect(function()
print("its running")
local selection = game:GetService("Selection")
local history = game:GetService("ChangeHistoryService")
local selected = selection:Get()
local tag = game:GetService("CollectionService")
if #selected == 0 then
warn("auroraSuite: Selection empty, make sure to select an ImageLabel, ImageButton or Decal. ")
return
end
local record = history:TryBeginRecording("auroraSuite: Insert icon")
if record then
for i, v in selected do
if v.ClassName == "ImageLabel" or v.ClassName == "ImageButton" then
v.Image = script.Parent.Image
if plugin:GetSetting("DebugMode") == true then
print("auroraSuite: Inserted icon into " .. v:GetFullName())
end
tag:AddTag(v, "auroraSuite-icon")
else if v.ClassName == "Decal" then
v.Texture = script.Parent.Image
if plugin:GetSetting("DebugMode") == true then
print("auroraSuite: Inserted icon into " .. v:GetFullName())
end
tag:AddTag(v, "auroraSuite-icon")
end
end
end
end
history:FinishRecording(record, Enum.FinishRecordingOperation.Commit)
end)
]]
task.wait(0.01)
end
When launching, both the old ones that weren’t generated with the generator and the new ones that were generated using the generator show up just fine (the generator ones are the ones that appear for the second time).
I’m using a slight deviation of the script used in the generated by script and non generated by script icons, but the slight deviation works fine if I paste it into the non generated ones.
Here’s the script inside each of the generated buttons:
script.Parent.MouseButton1Click:Connect(function()
print("its running")
local selection = game:GetService("Selection")
local history = game:GetService("ChangeHistoryService")
local selected = selection:Get()
local tag = game:GetService("CollectionService")
if #selected == 0 then
warn("auroraSuite: Selection empty, make sure to select an ImageLabel, ImageButton or Decal. ")
return
end
local record = history:TryBeginRecording("auroraSuite: Insert icon")
if record then
for i, v in selected do
if v.ClassName == "ImageLabel" or v.ClassName == "ImageButton" then
v.Image = script.Parent.Image
if plugin:GetSetting("DebugMode") == true then
print("auroraSuite: Inserted icon into " .. v:GetFullName())
end
tag:AddTag(v, "auroraSuite-icon")
else if v.ClassName == "Decal" then
v.Texture = script.Parent.Image
if plugin:GetSetting("DebugMode") == true then
print("auroraSuite: Inserted icon into " .. v:GetFullName())
end
tag:AddTag(v, "auroraSuite-icon")
end
end
end
end
history:FinishRecording(record, Enum.FinishRecordingOperation.Commit)
end)
Why does it not activate on the ones generated with the script? I can look into alternative solutions if need be, but there’s no reason for it not to activate in its current state.
Here is the full plugin file for anyone to tinker with:
aurorasuite.rbxmx (1.0 MB)