Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How can I have a plugin create a script and then write code inside of it?

I am creating a plugin for a loading intro, just testing the abilities of plugins, and I can't seem to figure out how to create a script inside of a frame and write code inside of it.

This is my only code inside of a Server Script.

I hear people say use modules and loadstrings, but modules can't be used as plugins and people say loadstrings aren't recommended. There are also people saying use coroutine, but I'm not 100% sure on how to use couroutine correctly.

local toolbar = plugin:CreateToolbar("Create LoadingGUI")
local button = toolbar:CreateButton("Create New LoadingGUI","Creates a New Loading GUI", " ")
local history = game:GetService("ChangeHistoryService")

local function createLoadingGUI()
--// First Frame
	--// Creates GUI
	local SetupGUI = Instance.new("ScreenGui")
	SetupGUI.ResetOnSpawn = false
	SetupGUI.Name = "SetupGUI"
	--// Creates Frame
	local Holder = Instance.new("Frame")
	Holder.Name = "Holder"
	Holder.Size = UDim2.new(0.5,0,0.5,0)
	Holder.AnchorPoint = Vector2.new(0.5,0.5)
	Holder.BackgroundColor3 = Color3.fromRGB(0,0,0)
	Holder.BackgroundTransparency = 0.5
	Holder.Parent = SetupGUI
	Holder.BorderSizePixel = 5
	Holder.BorderColor3 = Color3.fromRGB(10,10,10)
	Holder.Position = UDim2.new(-1.5,0,0.5,0)
	--// Front Design
	local Title = Instance.new("TextLabel")
	Title.Parent = Holder
	Title.Name = "Title"
	Title.Text = "Create A Loading GUI"
	Title.Size = UDim2.new(1,0,0.25,0)
	Title.TextScaled = true
	Title.TextWrapped = true
	Title.TextColor3 = Color3.fromRGB(255,255,255)
	Title.BackgroundTransparency = 1
	--// Create Button
	local NextButton = Instance.new("TextButton")
	NextButton.Parent = Holder
	NextButton.Size = UDim2.new(0.5,0,0.25,0)
	NextButton.BackgroundColor3 = Color3.fromRGB(25,25,25)
	NextButton.BorderSizePixel = 3
	NextButton.BorderColor3 = Color3.fromRGB(35,35,35)
	NextButton.Position = UDim2.new(0.5,0,0.75,0)
	NextButton.AnchorPoint = Vector2(0.5,0.75)
	NextButton.Text = "START"
	NextButton.TextScaled = true
	NextButton.TextWrapped = true
	NextButton.TextColor3 = Color3.fromRGB(200,25,10)
--// Second Frame
	--// Second Main Frame
	local SecondHolder = Instance.new("Frame")
	SecondHolder.Name = "SecondHolder"
	SecondHolder.Position = UDim2.new(1.5,0,0.5,0)
	SecondHolder.Size = UDim2.new(0.5,0,0.5,0)
	SecondHolder.AnchorPoint = Vector2.new(0.5,0.5)
	SecondHolder.BackgroundColor3 = Color3.fromRGB(0,0,0)
	SecondHolder.BackgroundTransparency = 0.5
	SecondHolder.Parent = SetupGUI
	SecondHolder.BorderSizePixel = 5
	SecondHolder.BorderColor3 = Color3.fromRGB(10,10,10)
end

button.Click:Connect(createLoadingGUI)

I have a button created and I want to have a localscript inside of it and when they click the button I want the frame to tween out. The only part I need help with is getting code inside of the localscript through a ServerScript.

1 comment

0

create a script then edit the source

1 answer

✓ Accepted answer

Hello, killerbrenden!

You can use script.Source to set a script code:

local script = Instance.new("Script")
script.Source = "print('Hello Roblox!')"
script.Parent = workspace

This script results in: Hello Roblox!

1 comment

0

Thank you for you're help

This discussion is preserved as it was. New answers, comments, and votes are closed.