I’m making a Plugin and I had a Local Script inside the frame, but when I went to test the plugin nothing worked, Are you able to use LocalScript inside of a Frame for a Plugin?
Okay, So it works, But I have to be playing the game in Studio. I want it to work while I’m developing too.
Can provide screenshots or videos of the issue and the code? Also anything in the output giving you errors?
There is a LocalScript inside of the Frame for the plugin that is inside of the Widget, That could be it but I’m not sure
Photo of plugin in studio while playing the game
Photo in studio while not playing the game
Any errors in output? Put prints throughout the script to debug it. Also please provide the script so I can take a look at it.
What script do you want to see, The script to create the plugin or the LocalScript?
The script you feel the problem is occurring in. But before you give me the script please put prints through all the scripts and see where it is bugging out.
Error:
Server Script:
local Toolbar = plugin:CreateToolbar("Roblox Studio Development Plugin")
local Button = Toolbar:CreateButton("RoGold", "Toggle the UI for the Studio Plugin.", "rbxassetid://1587492522")
local WidgetInfo = DockWidgetPluginGuiInfo.new(Enum.InitialDockState.Float, true, false, 200, 300, 150, 150)
local PluginFrame = script:WaitForChild("PluginFrame")
local Widget = plugin:CreateDockWidgetPluginGui("Studio Plugin", WidgetInfo)
local StudioService = game:GetService("Studio")
Button.Click:Connect(function()
if Widget.Visible == false then
Widget.Visible = true
else
Widget.Visible = false
end
end)
Widget.Title = "Roblox Studio Development Plugin"
PluginFrame.Parent = Widget
LocalScript:
local Parent = script.Parent
local Main = Parent.Main
local Dashboard = Main.Container.Dashboard
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local function formatTime(seconds)
local hours = math.floor(seconds / 3600)
local minutes = math.floor((seconds % 3600) / 60)
local secs = seconds % 60
return string.format("%02d:%02d:%02d", hours, minutes, secs)
end
local function AddCommas(Number)
local formattedNumber = tostring(Number)
formattedNumber = formattedNumber:reverse():gsub("(%d%d%d)","%1,"):reverse()
if formattedNumber:sub(1,1) == "," then
formattedNumber = formattedNumber:sub(2)
end
return formattedNumber
end
Dashboard.MainInfo.Info.UserInfo.AvatarIcon.Image = "rbxthumb://type=AvatarHeadShot&id=" .. tostring(LocalPlayer.UserId) .. "&w=180&h=180"
Dashboard.MainInfo.Info.UserInfo.Username.Text = LocalPlayer.Name
local descendants = game:GetDescendants()
local scriptCount = 0
for _, descendant in pairs(descendants) do
if descendant:IsA("Script") or descendant:IsA("LocalScript") or descendant:IsA("ModuleScript") then
scriptCount = scriptCount + 1
end
end
Dashboard.MainInfo.InstanceTracker.ScriptCount.Instances.Text = tostring(AddCommas(scriptCount))
local descendants = game:GetDescendants()
local partCount = 0
for _, descendant in pairs(descendants) do
if descendant:IsA("Part") or descendant:IsA("MeshPart") then
partCount = partCount + 1
end
end
Dashboard.MainInfo.InstanceTracker.PartCount.Instances.Text = tostring(AddCommas(partCount))
local descendants = game:GetDescendants()
local uiCount = 0
for _, descendant in pairs(descendants) do
if descendant:IsA("GuiObject") then
uiCount = uiCount + 1
end
end
Dashboard.MainInfo.InstanceTracker.UiCount.Instances.Text = tostring(AddCommas(uiCount))
local secondsPassed = 0
while true do
wait(1)
secondsPassed = secondsPassed + 1
local formattedTime = formatTime(secondsPassed)
Dashboard.MainInfo.TimeTracker.StudioTime.Time.Text = formattedTime
Dashboard.MainInfo.TimeTracker.WorkTime.Time.Text = formattedTime
end
I think you can only use server scripts with plugins, and dont worry if you have a UI for the plugin it will still work regularly (as if you were using a local script) with the server script
Here is the corrected script as it won’t really work locally
Script:
-- This script must be placed in the plugin's `Plugin Folder`
-- Create a toolbar in Roblox Studio
local Toolbar = plugin:CreateToolbar("Roblox Studio Development Plugin")
-- Create a button in the toolbar
local Button = Toolbar:CreateButton(
"RoGold",
"Toggle the UI for the Studio Plugin.",
"rbxassetid://1587492522"
)
-- Define the widget info
local WidgetInfo = DockWidgetPluginGuiInfo.new(
Enum.InitialDockState.Float,
true, -- initial enabled
false, -- initial enabled should override previous state
200, -- default width
300, -- default height
150, -- min width
150 -- min height
)
-- Create the DockWidgetPluginGui
local Widget = plugin:CreateDockWidgetPluginGui("StudioPlugin", WidgetInfo)
-- Set the widget's title
Widget.Title = "Roblox Studio Development Plugin"
-- Connect the button click event to toggle widget visibility
Button.Click:Connect(function()
Widget.Enabled = not Widget.Enabled
end)
-- Assuming `PluginFrame` is a descendant of the script, e.g., a ScreenGui or Frame
local PluginFrame = script:WaitForChild("PluginFrame")
PluginFrame.Parent = Widget
-- Main functionality in a LocalScript
local function initLocalScript()
local Parent = script.Parent
local Main = Parent.Main
local Dashboard = Main.Container.Dashboard
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local function formatTime(seconds)
local hours = math.floor(seconds / 3600)
local minutes = math.floor((seconds % 3600) / 60)
local secs = seconds % 60
return string.format("%02d:%02d:%02d", hours, minutes, secs)
end
local function AddCommas(Number)
local formattedNumber = tostring(Number)
formattedNumber = formattedNumber:reverse():gsub("(%d%d%d)", "%1,"):reverse()
if formattedNumber:sub(1,1) == "," then
formattedNumber = formattedNumber:sub(2)
end
return formattedNumber
end
Dashboard.MainInfo.Info.UserInfo.AvatarIcon.Image = "rbxthumb://type=AvatarHeadShot&id=" .. tostring(LocalPlayer.UserId) .. "&w=180&h=180"
Dashboard.MainInfo.Info.UserInfo.Username.Text = LocalPlayer.Name
local descendants = game:GetDescendants()
local scriptCount = 0
for _, descendant in pairs(descendants) do
if descendant:IsA("Script") or descendant:IsA("LocalScript") or descendant:IsA("ModuleScript") then
scriptCount = scriptCount + 1
end
end
Dashboard.MainInfo.InstanceTracker.ScriptCount.Instances.Text = tostring(AddCommas(scriptCount))
local partCount = 0
for _, descendant in pairs(descendants) do
if descendant:IsA("Part") or descendant:IsA("MeshPart") then
partCount = partCount + 1
end
end
Dashboard.MainInfo.InstanceTracker.PartCount.Instances.Text = tostring(AddCommas(partCount))
local uiCount = 0
for _, descendant in pairs(descendants) do
if descendant:IsA("GuiObject") then
uiCount = uiCount + 1
end
end
Dashboard.MainInfo.InstanceTracker.UiCount.Instances.Text = tostring(AddCommas(uiCount))
local secondsPassed = 0
while true do
wait(1)
secondsPassed = secondsPassed + 1
local formattedTime = formatTime(secondsPassed)
Dashboard.MainInfo.TimeTracker.StudioTime.Time.Text = formattedTime
Dashboard.MainInfo.TimeTracker.WorkTime.Time.Text = formattedTime
end
end
-- Start the local script functionality
initLocalScript()
Same issue, I added the new code and it doesn’t work unless I’m playing the game in studio
I’d like it to work when I’m playing the game and developing
Did you make everything work on the server side as on the client side won’t work?
I changed everything to the server side, Thanks
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.