-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathReplicatedTweeningClient.luau
More file actions
57 lines (42 loc) · 1.32 KB
/
ReplicatedTweeningClient.luau
File metadata and controls
57 lines (42 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
52
53
54
55
56
57
--// Author: 8ch99
--// Client replicated implementation of TweenService
--!native
--!optimize 2
local TweenService = game:GetService("TweenService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local BitBuffer = require(ReplicatedStorage:WaitForChild("BitBuffer"))
local ReplicatedTweening = require(ReplicatedStorage:WaitForChild("ReplicatedTweening"))
local Tweens = {}
local RunningTweens = {}
local Actions = {}
function Actions.Play(ID: string, Instance: Instance?, TweenInfo: buffer, Properties: buffer)
local Tween = Tweens[ID]
if Instance and not Tweens[ID] then
Tween = TweenService:Create(Instance, ReplicatedTweening:DeserializeTweenInfo(TweenInfo), ReplicatedTweening:DeserializeProperties(Properties))
Tweens[ID] = Tween
end
if Tween then
if RunningTweens[ID] then
task.cancel(RunningTweens[ID])
end
local Info = Tween.TweenInfo
Tween:Play()
RunningTweens[ID] = task.delay((Info.Time + Info.DelayTime) * (Info.RepeatCount + 1), function()
RunningTweens[ID] = nil
end)
end
end
function Actions.Cancel(ID: string)
local Thread = RunningTweens[ID]
if Thread then
task.cancel(Thread)
RunningTweens[ID] = nil
end
Tweens[ID]:Cancel()
end
ReplicatedTweening.Event.OnClientEvent:Connect(function(Action, ...)
Action = Actions[Action]
if Action then
return Action(...)
end
end)