-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLuau LocalScript
More file actions
97 lines (92 loc) · 2.79 KB
/
Luau LocalScript
File metadata and controls
97 lines (92 loc) · 2.79 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
local EnterBox = script.Parent.Box
local Redeem = EnterBox.Parent.Redeem
local Open = EnterBox.Parent.Parent.Sidebar.Container.Codes.ImageButton
local Player = game:GetService("Players").LocalPlayer
local ClickDB = false
local code_event = game:GetService("ReplicatedStorage").codeEvent
code_event.OnClientEvent:Connect(function(code_table)
local function shake()
local main_frame = EnterBox.Parent
local shake_duration = 3
local shake_speed = 0.1
local upper_limit = 8
local lower_limit = -4
for i=1,shake_duration do
local y_offset = math.random(lower_limit,upper_limit)
local x_offset = math.random(lower_limit,upper_limit)
local target = UDim2.new(main_frame.Position.X.Scale,x_offset,main_frame.Position.Y.Scale,y_offset)
main_frame:TweenPosition(target,Enum.EasingDirection.Out,Enum.EasingStyle.Linear,shake_speed,true)
wait(shake_speed)
end
main_frame:TweenPosition(UDim2.new(0.5,0,0.5,0),Enum.EasingDirection.Out,Enum.EasingStyle.Linear,shake_speed,true)
end
local function button_clicked()
local code_valid = false
for _, code_index in pairs(code_table) do
if EnterBox.Text == code_index[1] then
code_valid = true
break
end
end
if code_valid == true then
local plr_codes = Player['CodesFolder']
if plr_codes:FindFirstChild(EnterBox.Text) then
if plr_codes[EnterBox.Text].Value == false then
code_event:FireServer(EnterBox.Text)
EnterBox.TextColor3 = Color3.fromRGB(0, 170, 127)
EnterBox.TextEditable = false
EnterBox.Text = 'Code Redeemed!'
delay(1,function()
EnterBox.TextEditable = true
EnterBox.Text = ''
EnterBox.TextColor3 = Color3.fromRGB(171, 171, 171)
end)
wait(1.5)
script.Parent:TweenPosition(UDim2.new(0.5,0,1.5,0),"Out","Sine",0.5)
else
shake()
EnterBox.TextColor3 = Color3.fromRGB(255, 8, 61)
EnterBox.TextEditable = false
EnterBox.Text = 'Code Already Redeemed!'
delay(1.25,function()
EnterBox.TextEditable = true
EnterBox.Text = ''
EnterBox.TextColor3 = Color3.fromRGB(171, 171, 171)
end)
end
end
else
shake()
EnterBox.TextColor3 = Color3.fromRGB(255, 8, 61)
EnterBox.TextEditable = false
EnterBox.Text = 'Invalid Code!'
delay(1.25,function()
EnterBox.TextEditable = true
EnterBox.Text = ''
EnterBox.TextColor3 = Color3.fromRGB(171, 171, 171)
end)
end
end
local frame_open = false
Open.Activated:Connect(function()
if ClickDB == false then
ClickDB = true
Redeem.Parent.Visible = not frame_open
if frame_open == false then
frame_open = true
else
frame_open = false
end
wait(0.15)
ClickDB = false
end
end)
Redeem.Activated:Connect(function()
if ClickDB == false then
ClickDB = true
button_clicked()
wait(0.15)
ClickDB = false
end
end)
end)