This repository was archived by the owner on Sep 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.lua
More file actions
129 lines (104 loc) · 4.34 KB
/
main.lua
File metadata and controls
129 lines (104 loc) · 4.34 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
--[[
╭━━━╮╱╱╱╱╭╮╱╱╱╱╱╱╱╱╱╱╭━╮╭━╮╱╱╱╱╭╮╱╱╭╮
┃╭━━╯╱╱╱╱┃┃╱╱╱╱╱╱╱╱╱╱┃┃╰╯┃┃╱╱╱╱┃┃╱╱┃┃
┃╰━━┳━╮╭━╯┣┳━╮╭━━┳━━╮┃╭╮╭╮┣━━┳━╯┣╮╭┫┃╭━━╮
┃╭━━┫╭╮┫╭╮┣┫╭╮┫╭╮┃━━┫┃┃┃┃┃┃╭╮┃╭╮┃┃┃┃┃┃┃━┫
┃╰━━┫┃┃┃╰╯┃┃┃┃┃╰╯┣━━┃┃┃┃┃┃┃╰╯┃╰╯┃╰╯┃╰┫┃━┫
╰━━━┻╯╰┻━━┻┻╯╰┻━╮┣━━╯╰╯╰╯╰┻━━┻━━┻━━┻━┻━━╯
╱╱╱╱╱╱╱╱╱╱╱╱╱╱╭━╯┃
╱╱╱╱╱╱╱╱╱╱╱╱╱╱╰━━╯
// ModuleScript for endings.
// probably NOT optimized, you can optimize this yourself if you want to.
]]
local TweenService = game:GetService("TweenService")
local TweenInformation = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)
local TeleportService = game:GetService("TeleportService")
local PLACE_ID = 16871131982;
local BadgeService = game:GetService("BadgeService")
local badges = {
TestEnding = 2780397641298388;
}
local mainModule = {}
if game:GetService("RunService"):IsClient() then
warn("EndingModule does not allow client-sided scripts to run our function to prevent cheating.")
return
else
print("EndingModule is runnning on the server, as expected.")
end
-- MAIN FUNCTION
function mainModule:GiveEnding(player: Player, ending: string, nameString: string, descString: string, hintString: string)
-- BADGES
local hasBadge = BadgeService:UserHasBadgeAsync(player.UserId, badges[ending])
if not hasBadge then
BadgeService:AwardBadge(player.UserId, badges[ending])
end
-- GUI
local oldProperties = {}
for _, v in pairs(player.PlayerGui:GetDescendants()) do
if v:IsA("ScreenGui") then
v.Enabled = false
end
end
local gui = script.EndingGUI:Clone()
gui.Parent = player.PlayerGui
gui.Enabled = true
gui.Main.EndingName.Text = nameString
gui.Main.Description.Text = descString
if hintString then
gui.Main.Hint.Text = "HINT: "..hintString
else
gui.Main.Hint.Text = ""
end
for _, v in pairs(gui:GetDescendants()) do
if v:IsA("Frame") then
oldProperties[v] = {
BackgroundTransparency = v.BackgroundTransparency;
}
v.BackgroundTransparency = 1
elseif v:IsA("ImageLabel") or v:IsA("ImageButton") then
oldProperties[v] = {
BackgroundTransparency = v.BackgroundTransparency;
ImageTransparency = v.ImageTransparency;
}
v.ImageTransparency = 1
v.BackgroundTransparency = 1
elseif v:IsA("TextLabel") or v:IsA("TextButton") then
oldProperties[v] = {
BackgroundTransparency = v.BackgroundTransparency;
TextTransparency = v.TextTransparency;
}
v.TextTransparency = 1
v.BackgroundTransparency = 1
elseif v:IsA("UIStroke") then
oldProperties[v] = {
Transparency = v.Transparency;
}
v.Transparency = 1
end
end
for _, v in pairs(gui:GetDescendants()) do
if v:IsA("Frame") then
local tween = TweenService:Create(v, TweenInformation, {BackgroundTransparency = oldProperties[v].BackgroundTransparency})
tween:Play()
elseif v:IsA("ImageLabel") or v:IsA("ImageButton") then
local tween = TweenService:Create(v, TweenInformation, {ImageTransparency = oldProperties[v].ImageTransparency})
tween:Play()
local tween2 = TweenService:Create(v, TweenInformation, {BackgroundTransparency = oldProperties[v].BackgroundTransparency})
tween2:Play()
elseif v:IsA("TextLabel") or v:IsA("TextButton") then
local tween = TweenService:Create(v, TweenInformation, {TextTransparency = oldProperties[v].TextTransparency})
tween:Play()
local tween2 = TweenService:Create(v, TweenInformation, {BackgroundTransparency = oldProperties[v].BackgroundTransparency})
tween2:Play()
elseif v:IsA("UIStroke") then
local tween = TweenService:Create(v, TweenInformation, {Transparency = oldProperties[v].Transparency})
tween:Play()
end
end
-- REJOIN BUTTON
gui.Main.RejoinButton.MouseButton1Click:Once(function()
local access_code = TeleportService:ReserveServer(PLACE_ID)
TeleportService:TeleportToPrivateServer(PLACE_ID, access_code, {player}, "SpawnLocation", nil, script.TeleportScreen)
end)
end
return mainModule