-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodule.luau
More file actions
79 lines (65 loc) · 2.14 KB
/
module.luau
File metadata and controls
79 lines (65 loc) · 2.14 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
--SimpleTween by Bubu
--https://devforum.roblox.com/t/simpletween-a-module-to-help-you-animate-ui-and-much-more
--This module is licensed under the MIT LICENSE, more in the LICENSE script
local TweenService = game:GetService("TweenService")
local module = {}
function module.tween(instance: Instance, goal, duration: number, play: boolean): Tween
duration = duration or 1
play = play ~= false
local currentTween = TweenService:Create(instance, TweenInfo.new(duration), goal)
if play then
currentTween:Play()
end
return currentTween
end
function module.typewriteText(textElement, text: string, waitPerChar: number, playSound: boolean)
waitPerChar = waitPerChar or 0.05
playSound = playSound or false
if textElement then
for i = 1,#text,1 do
textElement.Text = string.sub(text,1,i)
task.wait(waitPerChar)
if playSound then
script.TypewriteClick:Play()
end
end
end
end
function module.hideObject(object: GuiObject, duration: number)
duration = duration or 1
if object then
local t = TweenService:Create(object, TweenInfo.new(duration), {Size = UDim2.fromScale(0,0)})
t:Play()
t.Completed:Connect(function()
object.Visible = false
end)
end
end
function module.showObject(object: GuiObject, targetSize: UDim2, duration: number)
duration = duration or 1
if object then
local t = TweenService:Create(object, TweenInfo.new(duration), {Size = targetSize})
t:Play()
t.Completed:Connect(function()
object.Size = targetSize
end)
end
end
function module.shakeCamera(humanoid: Humanoid, intensity: number, duration: number)
intensity = intensity or 0.1
duration = duration or 1
local originalOffset = humanoid.CameraOffset
local startTime = tick()
while tick() - startTime < duration do
local timeElapsed = tick() - startTime
local shakeOffset = Vector3.new(
Random.new().NextNumber(Random.new(), -intensity, intensity),
Random.new().NextNumber(Random.new(), -intensity, intensity),
Random.new().NextNumber(Random.new(), -intensity, intensity)
)
humanoid.CameraOffset = originalOffset + shakeOffset * (1 - (timeElapsed / duration))
task.wait()
end
humanoid.CameraOffset = originalOffset
end
return module