-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFilterTextForBlocks.luau
More file actions
35 lines (31 loc) · 1.15 KB
/
FilterTextForBlocks.luau
File metadata and controls
35 lines (31 loc) · 1.15 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
local TextService = game:GetService("TextService")
local letters = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}
local function getRandomLetter()
local randomIndex = math.random(1, #letters)
return letters[randomIndex]
end
local function filterAndSetText(textLabel)
local randomLetter = getRandomLetter()
local placeholderUserId = 0
local success, filteredTextResult = pcall(function()
return TextService:FilterStringAsync(randomLetter, placeholderUserId)
end)
if success then
local filteredText = filteredTextResult:GetNonChatStringForBroadcastAsync()
textLabel.Text = filteredText
else
textLabel.Text = randomLetter
end
end
local blocksModel = script.Parent
for _, block in blocksModel:GetChildren() do
if block:IsA("Part") then
local surfaceGui = block:FindFirstChildOfClass("SurfaceGui")
if surfaceGui then
local textLabel = surfaceGui:FindFirstChildOfClass("TextLabel")
if textLabel then
filterAndSetText(textLabel)
end
end
end
end