-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCode
153 lines (102 loc) · 3.23 KB
/
Code
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
--[[
Made by timothytheawesome (Scriptonix#6957)
Please give me credit if you use this in something.
--]]
local loa
local anim
local httpService = game:GetService('HttpService')
local categories = game:HttpGet('https://catalog.roblox.com/v1/categories')
local animationCategory = httpService:JSONDecode(categories).AvatarAnimations
local subCategory = game:HttpGet('https://catalog.roblox.com/v1/subcategories')
local emoteCategory = httpService:JSONDecode(subCategory).EmoteAnimations
local Market = game:GetService('MarketplaceService')
local emotesTable = {}
local cursor = ''
local function getid(id)
local is = game:GetObjects('rbxassetid://'..id)[1]
return is.AnimationId
end
while true do -- gets all existing emotes
local requestString = ('https://catalog.roblox.com/v1/search/items/details?Category=%s&Subcategory=%s&IncludeNotForSale=true&Limit=30&Cursor=%s'):format(
animationCategory, emoteCategory, cursor
)
local response = httpService:JSONDecode(game:HttpGet(requestString))
cursor = response.nextPageCursor
for _, data in ipairs(response.data) do
local i = string.split(string.lower(data.name),' -')[1]
emotesTable[i] = getid(data.id)
end
if not cursor then
break
end
end
local function GetAnimationID(animname) -- turns the name of the emote into a usable ID
return emotesTable[string.lower(animname)]
end
local function StopEmote() -- stops the emote
if loa then
loa:Stop()
end
if anim then
print(anim)
anim:Destroy()
end
local c = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
local anime = c:WaitForChild'Animate'
anime.Disabled = false
anim = nil
loa = nil
end
local function PlayEmote(animname) -- plays the emote based on the emote name
local animid = GetAnimationID(animname)
if anim then
StopEmote()
end
if animid then
local c = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
local anime = c:WaitForChild'Animate'
local hum = c:WaitForChild'Humanoid'
local humr = c:WaitForChild'HumanoidRootPart'
local p = humr.Position
anim = Instance.new('Animation',hum)
anim.AnimationId = animid
loa = hum:LoadAnimation(anim)
anime.Disabled = true
loa:Play(.1,1,1)
loa.Stopped:Connect(function()
if anim then
anim:Destroy()
end
local c = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
local anime = c:WaitForChild'Animate'
anime.Disabled = false
anim = nil
loa = nil
end)
hum.Jumping:Connect(function()
StopEmote()
end)
hum.Running:Connect(function(speed)
if speed > 0 then -- checks if the player is actually walking
StopEmote()
end
end)
end
end
while not game.Players.LocalPlayer do game:GetService'RunService'.RenderStepped:Wait() end
game.Players.LocalPlayer.DescendantAdded:Connect(function(v)
if v:IsA('TextLabel') and v.Text == "You can't use that Emote." then
v.Changed:Connect(function()
if v.Parent.Name == 'Frame' then
v.Parent.Visible = false
end
end)
end
end)
game.Players.LocalPlayer.Chatted:Connect(function(msg)
if (string.sub(msg, 1, 3) == "/e ") then
PlayEmote(string.sub(msg, 4))
elseif (string.sub(msg, 1, 7) == "/emote ") then
PlayEmote(string.sub(msg, 8))
end
end)