EDIT: You need to use server scripts for plugins as stated in @busterbob64’s reply. (This edit was for the people coming to this topic who wants the answer to what the titles says.)
EDIT: I have recently converted the team adder plugin gui to use Lua Widgets, which makes the plugin look a lot nicer.
I was working on a team adder plugin, and I couldn’t get the gui to work properly. All the scripts inside the gui never ran (They were local). So I changed them to server scripts and they still didn’t work. If you guys need all the code for the plugin, I may provide it in the replies.
I don’t think local scripts or server scripts run in the CoreGui or the DockWidgetPluginGui, you should be handling the entire GUI (mouse clicks, etc.) in the script that parents the gui to the correct place
Let me show you what I mean:
( this is a template obviously you need to get all the buttons to work )
local gui = script.Parent:WaitForChild("TeamPluginGui") -- assuming it's the gui
local teamFrame = gui.TeamFrame
local createTeamButton = teamFrame.CreateTeamButton
createTeamButton.MouseButton1Click:Connect(function()
-- script here
end)
gui.Parent = game:GetService("CoreGui")
That kind of just makes everyone more confusing, since my script looks like this, so I don’t know where to put your code in.
local ChangeHistoryService = game:GetService("ChangeHistoryService")
local enabled = false
local toolbar = plugin:CreateToolbar("Custom team adder")
local newTeamButton = toolbar:CreateButton("Create a team", "Make a team", "rbxassetid://28718513")
local function onNewTeamButtonClicked()
enabled = not enabled
if enabled then
script.Parent.TeamPluginGui:Clone().Parent = game:GetService("CoreGui")
else
if game:GetService("CoreGui"):FindFirstChild("TeamPluginGui") then
game.CoreGui.TeamPluginGui:Destroy()
end
end
end
newTeamButton.Click:Connect(onNewTeamButtonClicked)
local ChangeHistoryService = game:GetService("ChangeHistoryService")
local enabled = false
local toolbar = plugin:CreateToolbar("Custom team adder")
local newTeamButton = toolbar:CreateButton("Create a team", "Make a team", "rbxassetid://28718513")
local function onNewTeamButtonClicked()
enabled = not enabled
if enabled then
local teamPluginGui = script.Parent.TeamPluginGui:Clone()
teamPluginGui.TeamFrame.CreateTeamButton.MouseButton1Click:Connect(function()
-- script goes here
end)
teamPluginGui.Parent = game:GetService("CoreGui")
else
if game:GetService("CoreGui"):FindFirstChild("TeamPluginGui") then
game.CoreGui.TeamPluginGui:Destroy()
end
end
end
newTeamButton.Click:Connect(onNewTeamButtonClicked)
Pretty weird, it should be working as long as there are no errors, are you sure you are saving the local plugin correctly?
To save it correctly you have to manually select all the descendants in the folder, the folder too (it’s all in a folder right?) and then save it as a local plugin, this is weird but I had such issues
No, I fixed it, but I accidently made a new plugin instead of saving the plugin as the old one. I am getting another error, but I think I could fix it on my own, the error only appears when I press the button, which is good.
EDIT: No I was wrong, I have no idea what I did, but something happens I guess, it shouldn’t be too bad.
I’m having trouble getting everything to work, if you know how to fix, please do so:
local ChangeHistoryService = game:GetService("ChangeHistoryService")
local enabled = false
local toolbar = plugin:CreateToolbar("Custom team adder lol")
local newTeamButton = toolbar:CreateButton("Create a team", "Make a team", "rbxassetid://28718513")
local function onNewTeamButtonClicked()
enabled = not enabled
if enabled then
local teamPluginGui = script.Parent.TeamPluginGui:Clone()
coroutine.wrap(function()
while task.wait() do
local R = tonumber(teamPluginGui:WaitForChild("TeamFrame").ColorPicker.R.Text)
local G = tonumber(teamPluginGui:WaitForChild("TeamFrame").ColorPicker.G.Text)
local B = tonumber(teamPluginGui:WaitForChild("TeamFrame").ColorPicker.B.Text)
teamPluginGui.TeamFrame.ColorPicker.ColorShower.BackgroundColor3 = Color3.fromRGB()
end
end)()
teamPluginGui.TeamFrame.CreateTeamButton.MouseButton1Click:Connect(function()
local newTeam = Instance.new("Team")
local color = BrickColor.new(teamPluginGui.TeamFrame.ColorPicker.ColorShower.BackgroundColor3)
local name = teamPluginGui.TeamFrame.TeamNameBox.Text
newTeam.Parent = game:GetService("Teams")
end)
teamPluginGui.Parent = game:GetService("CoreGui")
else
if game:GetService("CoreGui"):FindFirstChild("TeamPluginGui") then
game.CoreGui.TeamPluginGui:Destroy()
end
end
end
newTeamButton.Click:Connect(onNewTeamButtonClicked)