-------------
--- INDEX ---
-------------
--// DECLARABLES
local uis = game:GetService("UserInputService");
local bGui = script.Parent;
local inside = bGui.Inside;
local CurrentTime;
---------------------
--- INTIALIZATION ---
---------------------
local tween = game:GetService("TweenService"):Create(inside, TweenInfo.new(1.98), {Size = UDim2.new(0.67, 0,0.604,0});
uis.InputBegan:Connect(function(key, proc)
if proc then return; end
if key.KeyCode == Enum.KeyCode.E then
if (workspace.CurrentCamera.CFrame.Position - script.Parent.parent.Position).magnitude > script.Parent.MaxDistance then return; end
currentTime = tick();
inside.Visible = true;
tween:Play();
end)
uis.InputEnded:Connect(function(key, proc)
if proc then return; end
if key.KeyCode == Enum.KeyCode.E then
if math.floor(tick() - CurrentTime) >= 1.99 then
inside.Visible = false;
inside.Size = UDUim2.new(0.297, 0, 0.275, 0);
print("In time");
else
tween:Pause()
print("released at wrong time");
end
end
end)
Here’s a more readable block of code with formatting made to be compatible with Roblox’s DevForum’s formatting. Try this one out.
EDIT1: There was a small mistake with tween, forgot to close the bracket/goal with the closing bracket.