-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclientMain.lua
More file actions
51 lines (41 loc) · 1.32 KB
/
clientMain.lua
File metadata and controls
51 lines (41 loc) · 1.32 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
local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local ContextActionService = game:GetService("ContextActionService")
local bind = require(script.Parent.bind)
local Comment = require(script.Parent.Comment)
local AccessList = require(script.Parent.AccessList)
local RenderstepTracker = require(script.Parent.RenderstepTracker)
local AddCommentHud = require(script.Parent.AddCommentHud)
-- Don't show comments or let people comment if they don't have access
if not AccessList.clientQueryHasAccess() then
return
end
-- Make CommentScreenGui under PlayerGui
local commentScreenGui = Instance.new("ScreenGui")
commentScreenGui.Name = "CommentScreenGui"
commentScreenGui.Parent = Players.LocalPlayer.PlayerGui
commentScreenGui.ResetOnSpawn = false
local unbind, addCommentHud;
local function teardown()
unbind()
unbind = nil
RenderstepTracker.uninstall()
addCommentHud:Destroy()
end
local function setup()
-- Track rendersteps
RenderstepTracker.install()
-- Bind comments
unbind = bind("Comment", Comment)
-- Add the comment HUD
addCommentHud = AddCommentHud.new(teardown)
end
-- Toggle visibility when the tab key is pressed
ContextActionService:BindAction("ToggleCommentVisibility", function()
if unbind then
teardown()
else
setup()
end
end, false, Enum.KeyCode.Tab)
setup()