-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.lua
More file actions
280 lines (254 loc) · 7.73 KB
/
main.lua
File metadata and controls
280 lines (254 loc) · 7.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
-- ScriptPlayground v3.6
-- Fully Local, MacSploit-safe, with console and line numbers
--// SERVICES
local Players = game:GetService("Players")
local UIS = game:GetService("UserInputService")
local player = Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
--// CONSTANTS
local MIN_WIDTH = 420
local MIN_HEIGHT = 260
local LINE_NUM_WIDTH = 40
--// THEME (Catppuccin Mocha)
local Theme = {
Base = Color3.fromRGB(30, 30, 46),
Mantle = Color3.fromRGB(24, 24, 37),
Crust = Color3.fromRGB(17, 17, 27),
Text = Color3.fromRGB(205, 214, 244),
Subtext = Color3.fromRGB(166, 173, 200),
Surface0 = Color3.fromRGB(49, 50, 68),
Surface1 = Color3.fromRGB(69, 71, 90),
Green = Color3.fromRGB(166, 227, 161),
Red = Color3.fromRGB(243, 139, 168),
}
--// HELPERS
local function round(obj, r)
local c = Instance.new("UICorner")
c.CornerRadius = UDim.new(0, r)
c.Parent = obj
end
local SAFE_LOADSTRING = loadstring or (getgenv and getgenv().loadstring)
--// GUI ROOT
local gui = Instance.new("ScreenGui")
gui.Name = "ScriptPlayground"
gui.ResetOnSpawn = false
gui.Parent = playerGui
--// MAIN WINDOW
local main = Instance.new("Frame")
main.Size = UDim2.fromOffset(620, 500)
main.Position = UDim2.fromScale(0.5, 0.5) - UDim2.fromOffset(310, 250)
main.BackgroundColor3 = Theme.Base
main.ClipsDescendants = true
main.Parent = gui
round(main, 14)
local stroke = Instance.new("UIStroke")
stroke.Color = Theme.Surface1
stroke.Thickness = 1
stroke.Parent = main
--// TITLE BAR
local title = Instance.new("Frame")
title.Size = UDim2.new(1, 0, 0, 36)
title.BackgroundColor3 = Theme.Mantle
title.Parent = main
round(title, 14)
local titleLabel = Instance.new("TextLabel")
titleLabel.Size = UDim2.new(1, -60, 1, 0)
titleLabel.Position = UDim2.fromOffset(12, 0)
titleLabel.BackgroundTransparency = 1
titleLabel.Text = "ScriptPlayground"
titleLabel.Font = Enum.Font.SourceSansSemibold
titleLabel.TextSize = 16
titleLabel.TextXAlignment = Enum.TextXAlignment.Left
titleLabel.TextColor3 = Theme.Text
titleLabel.Parent = title
local close = Instance.new("TextButton")
close.Size = UDim2.fromOffset(26, 26)
close.Position = UDim2.new(1, -34, 0, 5)
close.Text = "×"
close.Font = Enum.Font.SourceSansBold
close.TextSize = 22
close.TextColor3 = Theme.Text
close.BackgroundColor3 = Theme.Red
close.Parent = title
round(close, 6)
close.MouseButton1Click:Connect(function()
gui:Destroy()
end)
--// EDITOR CONTAINER
local editorContainer = Instance.new("Frame")
editorContainer.Position = UDim2.fromOffset(10, 46)
editorContainer.Size = UDim2.new(1, -20, 0, 300)
editorContainer.BackgroundColor3 = Theme.Crust
editorContainer.ClipsDescendants = true
editorContainer.Parent = main
round(editorContainer, 10)
--// LINE NUMBERS
local lines = Instance.new("TextLabel")
lines.Size = UDim2.new(0, LINE_NUM_WIDTH, 1, 0)
lines.BackgroundTransparency = 1
lines.TextXAlignment = Enum.TextXAlignment.Right
lines.TextYAlignment = Enum.TextYAlignment.Top
lines.Font = Enum.Font.Code
lines.TextSize = 14
lines.RichText = true
lines.TextColor3 = Theme.Subtext
lines.Text = "1"
lines.Parent = editorContainer
--// TEXTBOX (EDITOR)
local editor = Instance.new("TextBox")
editor.Position = UDim2.fromOffset(LINE_NUM_WIDTH, 0)
editor.Size = UDim2.new(1, -LINE_NUM_WIDTH, 1, 0)
editor.BackgroundTransparency = 1
editor.ClearTextOnFocus = false
editor.MultiLine = true
editor.TextWrapped = false
editor.TextXAlignment = Enum.TextXAlignment.Left
editor.TextYAlignment = Enum.TextYAlignment.Top
editor.Font = Enum.Font.Code
editor.TextSize = 14
editor.TextColor3 = Theme.Text
editor.Text = ""
editor.Parent = editorContainer
--// UPDATE LINE NUMBERS
local function updateLines()
local text = editor.Text
local count = select(2, text:gsub("\n", "")) + 1
local nums = {}
for i = 1, count do nums[i] = tostring(i) end
lines.Text = table.concat(nums, "\n")
end
editor:GetPropertyChangedSignal("Text"):Connect(updateLines)
updateLines()
--// OUTPUT CONSOLE
local console = Instance.new("TextLabel")
console.Size = UDim2.new(1, -20, 0, 130)
console.Position = UDim2.fromOffset(10, 360)
console.BackgroundColor3 = Theme.Surface0
console.TextColor3 = Theme.Text
console.TextXAlignment = Enum.TextXAlignment.Left
console.TextYAlignment = Enum.TextYAlignment.Top
console.TextWrapped = true
console.RichText = true
console.Font = Enum.Font.Code
console.TextSize = 14
console.Text = ""
console.Parent = main
round(console, 6)
local function printConsole(...)
local msgs = {}
for i,v in ipairs({...}) do
msgs[#msgs+1] = tostring(v)
end
console.Text = table.concat(msgs,"\t") .. "\n" .. console.Text
end
--// RUN BUTTON
local runButton = Instance.new("TextButton")
runButton.Size = UDim2.fromOffset(100, 30)
runButton.Position = UDim2.fromOffset(510, 360) -- below editor
runButton.BackgroundColor3 = Theme.Green
runButton.Text = "Run"
runButton.Font = Enum.Font.SourceSansBold
runButton.TextSize = 16
runButton.TextColor3 = Theme.Text
runButton.Parent = main
round(runButton, 6)
runButton.MouseButton1Click:Connect(function()
if not SAFE_LOADSTRING then
printConsole("loadstring not available in this thread")
return
end
local fn, err = SAFE_LOADSTRING(editor.Text)
if not fn then
printConsole("Compile error: "..tostring(err))
return
end
local ok, res = pcall(fn)
if not ok then
printConsole("Runtime error: "..tostring(res))
else
printConsole("Executed successfully")
end
end)
--// DRAGGING
do
local dragging=false
local startMouse, startPos
title.InputBegan:Connect(function(i)
if i.UserInputType == Enum.UserInputType.MouseButton1 then
dragging=true
startMouse=i.Position
startPos=main.Position
end
end)
UIS.InputChanged:Connect(function(i)
if dragging and i.UserInputType == Enum.UserInputType.MouseMovement then
local delta = i.Position - startMouse
main.Position = startPos + UDim2.fromOffset(delta.X, delta.Y)
end
end)
UIS.InputEnded:Connect(function(i)
if i.UserInputType == Enum.UserInputType.MouseButton1 then
dragging=false
end
end)
end
--// RESIZING
local function resizeHandle(size,pos,fn)
local h = Instance.new("Frame")
h.Size = size
h.Position = pos
h.BackgroundTransparency = 1
h.Active = true
h.Parent = main
local resizing=false
local startMouse, startSize, startPos
h.InputBegan:Connect(function(i)
if i.UserInputType==Enum.UserInputType.MouseButton1 then
resizing=true
startMouse=i.Position
startSize=main.Size
startPos=main.Position
end
end)
UIS.InputChanged:Connect(function(i)
if resizing and i.UserInputType==Enum.UserInputType.MouseMovement then
fn(i.Position-startMouse,startSize,startPos)
end
end)
UIS.InputEnded:Connect(function(i)
if i.UserInputType==Enum.UserInputType.MouseButton1 then
resizing=false
end
end)
end
-- right
resizeHandle(UDim2.new(0,6,1,-20), UDim2.new(1,-3,0,10), function(d,s)
main.Size = UDim2.fromOffset(math.max(MIN_WIDTH, s.X.Offset+d.X), s.Y.Offset)
end)
-- bottom
resizeHandle(UDim2.new(1,-20,0,6), UDim2.new(0,10,1,-3), function(d,s)
main.Size = UDim2.fromOffset(s.X.Offset, math.max(MIN_HEIGHT, s.Y.Offset+d.Y))
end)
-- left
resizeHandle(UDim2.new(0,6,1,-20), UDim2.new(0,-3,0,10), function(d,s,p)
local w = math.max(MIN_WIDTH, s.X.Offset-d.X)
main.Size = UDim2.fromOffset(w, s.Y.Offset)
main.Position = p + UDim2.fromOffset(s.X.Offset-w, 0)
end)
-- top
resizeHandle(UDim2.new(1,-20,0,6), UDim2.new(0,10,0,-3), function(d,s,p)
local h = math.max(MIN_HEIGHT, s.Y.Offset-d.Y)
main.Size = UDim2.fromOffset(s.X.Offset, h)
main.Position = p + UDim2.fromOffset(0, s.Y.Offset-h)
end)
-- bottom-right corner
resizeHandle(UDim2.fromOffset(14,14), UDim2.new(1,-14,1,-14), function(d,s)
main.Size = UDim2.fromOffset(math.max(MIN_WIDTH, s.X.Offset+d.X), math.max(MIN_HEIGHT, s.Y.Offset+d.Y))
end)
--// RIGHT ALT TOGGLE
UIS.InputBegan:Connect(function(i,gp)
if gp then return end
if i.KeyCode == Enum.KeyCode.RightAlt then
gui.Enabled = not gui.Enabled
end
end)